Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import os
- import datetime
- # Create time-stamp string for folder and file names
- now = datetime.datetime.now()
- now_string = str(now.strftime("%Y-%m-%d, %A, %H:%M:%S"))
- now_string_with_text = "The current details for today are... " + now_string
- #%Y = Year
- #%m = Month
- #%d = Day
- #%A = Day of the week
- #%H = Hour
- #%M = Minute
- #%S = Second
- print now_string
- print now_string_with_text
- #os.system("touch demo_file" + now_string)
- bin_path_name = os.getenv("HOME")+"/bin/"
- usr_bin_path_name = "/usr/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 ''' + now_string + '''
- # http//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
- #Create the script
- echo "#!/bin/bash" | tee ~/bin/$RESPONSE.sh
- echo "#Filename:$RESPONSE.sh" | tee -a ~/bin/$RESPONSE.sh
- echo "#Released under a GPLv3 Licence by Clockwork PC" | tee -a ~/bin/$RESPONSE.sh
- #Create removal script
- echo "#!/bin/bash" | tee ~/bin/remove_$RESPONSE.sh
- echo "#Filename:remove_$RESPONSE.sh" | tee -a ~/bin/remove_$RESPONSE.sh
- echo "#Released under a GPLv3 Licence by Clockwork PC" | tee -a ~/bin/remove_$RESPONSE.sh
- echo "sudo rm -v -rf ~/bin/$RESPONSE.SH /usr/bin/$RESPONSE.sh ~/bin/remove_$RESPONSE.sh /usr/bin/remove_$RESPONSE.sh" | tee -a ~/bin/remove_$RESPONSE.sh
- sudo chmod +x ~/bin/$RESPONSE.sh
- sudo chmod +x ~/bin/remove_$RESPONSE.sh
- sudo ln -s ~/bin/$RESPONSE.sh /usr/bin/$RESPONSE.sh
- sudo chmod +x /usr/bin/$RESPONSE.sh
- nano ~/bin/$RESPONSE.sh
- '''
- #Python script generator
- pythonGen = '''#!/usr/bin/python
- # Released under a GPLv3 Licence by Clockwork PC ''' + now_string + '''
- # 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"
- rm_pythonfile = "remove_" + filename + ".sh"
- 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
- # 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('echo "#!/usr/bin/python" | tee ' + rm_pythonfile)
- f = open(rm_pythonfile, "a")
- f.write("#"+rm_pythonfile+"""
- sudo rm -vrf """ + pythonfile + " " + "/usr/bin/" + filename + ".py" + " " + "~/bin/" + rm_pythonfile + " " + "/usr/bin/" + rm_pythonfile
- """)
- f.close()
- os.system("chmod -v +x " + pythonfile)
- os.system("sudo ln -sv " + pythonfile + " /" + "usr/bin/" + filename + ".py")
- os.system("chmod -v +x " + "~/bin/" + rm_pythonfile)
- os.system("sudo ln -sv " + "~/bin/" + rm_pythonfile + " /" + "usr/bin/" + rm_pythonfile)
- os.system("nano " + 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 -v"+ " " + bashGenFile + " " + bashGenUsr + " " + pythonGenFile + " " + pythonGenUsr + " " + rmScriptsFile + " " + rmScriptsUsr
- print bashGenFile
- print pythonGenFile
- print rmScriptsFile
- os.system("touch " + bashGenFile)
- f = open(bashGenFile, "a")
- f.write(bashGen)
- f.close()
- os.system("sudo ln -s " + bashGenFile + " " + bashGenUsr)
- os.system("touch " + pythonGenFile)
- g = open(pythonGenFile, "a")
- g.write(pythonGen)
- g.close()
- os.system("sudo ln -s " + pythonGenFile + " " + pythonGenUsr)
- os.system("touch " + rmScriptsFile)
- h = open(rmScriptsFile, "a")
- h.write(rmScripts)
- h.close()
- os.system ("sudo ln -s " + rmScriptsFile + " " + rmScriptsUsr)
- os.system("chmod +x -v " + bashGenFile)
- os.system("chmod +x -v " + pythonGenFile)
- #os.system("chmod u+x -v " + rmScripts)
- #os.system("xcowsay Your scripts are ready")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement