Gracias :3
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
#Users name (the same of the /home/<user_name> folder this must exist!)
{"user_name" : "astinx",
#The file structure of your environment
"filestructure" : "dev/tools/eclipse
dev/tools/smalltalk
dev/tools/ada
dev/tools/pl1
dev/tools/blender
dev/tools/php
dev/tools/python
dev/tools/c
dev/tools/ruby
dev/tools/actionscript
dev/tools/js
dev/frameworks/java/grails
dev/frameworks/java/play
dev/frameworks/java/spring
dev/frameworks/java/struct
dev/frameworks/java/gwt
dev/flash/flex
dev/frameworks/python/django
dev/frameworks/php/codeigniter
dev/frameworks/php/symphony
dev/frameworks/myframeworks
dev/references/hibernate
dev/references/spring
dev/references/blazeds
dev/workspaces/eclipseworksheet
dev/workspaces/phpworksheet
dev/servers
dev/scripts/python
dev/scripts/bash
dev/scripts/ruby
repos/git
repos/svn
books
college/mypapers
media/video
media/music
media/images
job",
#Repositories that you wanna make a checkout
"repositories_checkout" : "svn://...",
#Packages that you wanna install
"packages" : "geany
virtualbox-ose
pgadmin3",
#External devices like ntfs partitions that you wanna have every time mounted
"external_devices" : "/dev/sda3 => externalntfs",
#.deb files that you wanna install (they must be at the same level of this file and init_script.py file)
"backup_debs" : "google-chrome.deb",
#.tar, .giz or .zip that you wanna extract in some of the filestructure folder.
#The sintax is <file_name> => <destination_folder> with <extension>
"backup_files" : "eclipse_environment.zip => /dev/tools/eclipse with .zip
webdevelop.tar => /dev/tools/php with .tar",
#Anothers scripts that you wanna run when this script finishs
#The sintax is <script_name> with <bash|python|anything what make it run>
"anothers" : "java_install_script.sh with bash
hi.py with python"}
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
#
# init_script.py
#
# Copyright 2012 astinx <astinx@astinxmachina>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import datetime
import sys
import os
import subprocess
import json
import re
# This is the only thing that you can touch of this script, the config file absolute path.
config_path = "/home/astinx/dev/scripting/bash/config"
comment_regex = "(\A#.*\n*)"
whiteline_regex = "(\A\s*\Z)"
# First, we clean the config file, this is, erase all the comments
config_file = file(config_path,"r")
# A temporary file to put the parsed config file, without comments
config_temp = file(config_path+"_temp","w")
for line in config_file:
if (not (re.match(comment_regex+"|"+whiteline_regex,line))):
config_temp.write(line)
config_file.close()
config_temp.close()
# Now we clean the \n like dev/asd\ndev/qwe", to dec/asd,dev/qwe",
config_json = file(config_path+"_json","w")
config_temp = file(config_path+"_temp","r")
for line in config_temp:
# If is something like '"packages" : "geany'
if (re.match(".*\n\Z",line) and (not(re.match('.*\",\n\Z',line))) and (not(re.match("({)|(.*})",line)))):
line = line.replace("\n",", ")
line = line.replace("\t","")
config_json.write(line)
else:
line = line.replace("\t","")
config_json.write(line)
config_json.close()
config_temp.close()
# Well the config file is cleaned, now we can open it as a JSON object
config_path = "/home/astinx/dev/scripting/bash/config"
config_path = config_path + "_json"
jsonfile = file(config_path,"r")
json_string = jsonfile.read()
jsonfile.close()
json_obj = json.loads(json_string)
config_dictionary = dict(json_obj)
# Now we get the environment variables from the JSON
user_name = config_dictionary.get("user_name")
filestructure = config_dictionary.get("filestructure")
repositories_checkout = config_dictionary.get("repositories_checkout")
packages = config_dictionary.get("packages")
external_devices = config_dictionary.get("external_devices")
backup_debs = config_dictionary.get("backup_debs")
backup_files = config_dictionary.get("backup_files")
anothers = config_dictionary.get("anothers")
#We build the filestructure
for directory in filestructure.split(','):
print "Building "+directory+" ...\n"
try:
os.system("mkdir -p "+directory)
except OSError, e:
print "No se pudo crear el directorio ["+str(e)+"]"
except ValueError, e:
print "Uno de los directorios ingresados es ilegible ["+str(e)+"]"