Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import os
- bin_path_name = os.getenv("HOME")+"/bin/"
- usr_bin_path_name = "/usr/local/bin/"
- print bin_path_name
- if not os.path.isdir == bin_path_name:
- os.mkdir(bin_path_name)
- else:
- print bin_path_name
- #BASH Generator
- bashGen = '''#!/bin/bash
- #cpcbash.sh
- # Released under a GPLv3 Licence by Clockwork PC 2012
- # www.clockworkpc.com.au
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- echo "What do you want to call your BASH script?"
- read RESPONSE
- echo "#!/bin/bash" | tee $RESPONSE.sh
- echo "#Filename:$RESPONSE.sh" | tee -a $RESPONSE.sh
- echo "#Released under a GPLv3 Licence by Clockwork PC" | tee -a $RESPONSE.sh
- chmod +x $RESPONSE.sh
- sudo ln -s ~/bin/$RESPONSE.sh /usr/local/bin/$RESPONSE.sh
- sudo chmod +x /usr/local/bin/$RESPONSE.sh
- gedit $RESPONSE.sh
- '''
- pythonGen = '''#!/usr/bin/python
- # Released under a GPLv3 Licence by Clockwork PC 2012
- # www.clockworkpc.com.au
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- import os
- filename=raw_input("What do you want to call your Python file? ")
- folder = os.getenv("HOME")+"/bin/"
- pythonfile = folder + filename + ".py"
- print folder
- print pythonfile
- os.system('echo "#!/usr/bin/python" | tee ' + pythonfile)
- f = open(pythonfile, "a")
- f.write("#"+pythonfile+"""
- # Released under a GPLv3 Licence by Clockwork PC 2012
- # www.clockworkpc.com.au
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- """)
- f.close()
- os.system("chmod -v +x " + pythonfile)
- os.system("sudo ln -sv " + pythonfile + " /" + "usr/local/bin/" + filename + ".py")
- os.system("gedit " + pythonfile)
- os.system("xcowsay 'Your Python script is ready!'")
- '''
- bashGenName = "cpcbash.sh"
- bashGenFile = bin_path_name + bashGenName
- bashGenUsr = usr_bin_path_name+bashGenName
- pythonGenName = "cpcpython.py"
- pythonGenFile = bin_path_name + pythonGenName
- pythonGenUsr = usr_bin_path_name+pythonGenName
- rmScriptsName = "rmscripts.sh"
- rmScriptsFile = bin_path_name + rmScriptsName
- rmScriptsUsr = usr_bin_path_name+rmScriptsName
- #Remove scripts and symlinks
- rmScripts = "#!/bin/bash"+"""
- """+"sudo rm"+ " " + bashGenFile + " " + bashGenUsr + " " + pythonGenFile + " " + pythonGenUsr
- print bashGenFile
- print pythonGenFile
- print rmScriptsFile
- os.system("touch " + bashGenFile)
- os.system("touch " + pythonGenFile)
- os.system("touch " + rmScriptsFile)
- os.system("sudo apt-get install xcowsay && xcowsay how do you like them apples")
- f = open(bashGenFile, "a")
- f.write(bashGen)
- os.system ("sudo ln -s " + bashGenFile + " " + bashGenUsr)f.close()
- os.system("chmod +x " + bashGenFile)
- g = open(pythonGenFile, "a")
- g.write(pythonGen)
- g.close()
- os.system("chmod +x " + pythonGenFile)
- os.system ("sudo ln -s " + pythonGenFile + " " + pythonGenUsr)
- h = open(rmScriptsFile, "a")
- h.write(rmScripts)
- h.close()
- os.system("chmod +x " + rmScripts)
- os.system ("sudo ln -s " + rmScriptsFile + " " + rmScriptsUsr)
- os.system("xcowsay Your scripts are ready")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement