Skip to content

Commit

Permalink
run instructions is now working
Browse files Browse the repository at this point in the history
  • Loading branch information
gj1118 committed Nov 12, 2016
1 parent 19ced92 commit 08880a4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 51 deletions.
47 changes: 24 additions & 23 deletions installTools.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,40 @@
<apps>
<app name="svn" install="true" force="true" uninstall="true">
<config>
<copydirectory sourcedirectory="D:\pythonChocolateyTestFolder\Gagan" targetdirectory="D:\pythonChocolateyTestFolder\Gagan2" active="true"></copydirectory>
<deletedirectory active="true">D:\pythonChocolateyTestFolder\Gagan</deletedirectory>
<makedirectory active="true">D:\pythonChocolateyTestFolder\Gagan\Test</makedirectory>
<filedelete active="true">D:\pythonChocolateyTestFolder\test.txt</filedelete>
<downloadfile source="http://Mysite/repository/myFiles.txt" target="D:\pythonChocolateyTestFolder\Gagan\Test" active="true" > </downloadfile>
<copyfile sourceFile="D:\pythonChocolateyTestFolder\Gagan\Test\myFiles.txt" targetDirectory = "D:\pythonChocolateyTestFolder" newFileName ="test.txt" active="true" ></copyfile>
<copydirectory sourcedirectory="D:\pythonChocolateyTestFolder\Gagan" targetdirectory="D:\pythonChocolateyTestFolder\Gagan2" active="false"></copydirectory>
<deletedirectory active="false">D:\pythonChocolateyTestFolder\Gagan</deletedirectory>
<makedirectory active="false">D:\pythonChocolateyTestFolder\Gagan\Test</makedirectory>
<filedelete active="false">D:\pythonChocolateyTestFolder\test.txt</filedelete>
<downloadfile source="http://Mysite/repository/myFiles.txt" target="D:\pythonChocolateyTestFolder\Gagan\Test" active="false" > </downloadfile>
<runcommand active="true">notepad C:\Windows\System32\drivers\etc\hosts </runcommand>
<copyfile sourceFile="D:\pythonChocolateyTestFolder\Gagan\Test\myFiles.txt" targetDirectory = "D:\pythonChocolateyTestFolder" newFileName ="test.txt" active="false" ></copyfile>
</config>
</app>
<app name="tortoisesvn" install="true"></app>
<app name="git.install" install="true"></app>
<app name="sourcetree" install="true"></app>
<app name="github" install="true"></app>
<app name="tortoisesvn" install="false"></app>
<app name="git.install" install="false"></app>
<app name="sourcetree" install="false"></app>
<app name="github" install="false"></app>
<!-- browsers -->
<app name="googlechrome" install="true"></app>
<app name="opera" install="true"></app>
<app name="firefox" install="true"></app>
<app name="googlechrome" install="false"></app>
<app name="opera" install="false"></app>
<app name="firefox" install="false"></app>
<!-- cli tools -->
<app name="curl" install="true"></app>
<app name="wget" install="true"></app>
<app name="conemu" install="true"></app>
<app name="curl" install="false"></app>
<app name="wget" install="false"></app>
<app name="conemu" install="false"></app>
<app name="cmder" install="false"></app>
<!-- archives -->
<app name="7zip.install" install="true"></app>
<app name="7zip.install" install="false"></app>
<!-- server side programs -->
<app name="nodejs.install" install="true"></app>
<app name="ruby" install="true"></app>
<app name="nodejs.install" install="false"></app>
<app name="ruby" install="false"></app>
<app name="python" install="false"></app> <!-- will install python3 -->
<app name="python2" install="false"></app> <!-- will install python 2 -->
<app name="php" install="true"></app>
<app name="php" install="false"></app>
<!-- local tools -->
<app name="ccleaner" install="true"></app>
<app name="ccleaner" install="false"></app>
<app name="chocolateygui" install="false"></app>
<app name="teamviewer" install="true"></app>
<app name="teamviewer" install="false"></app>
<app name="urlrewrite" install="false"></app>
<app name="beyondcompare" install="false"></app>
<app name="winscp.install" install="false"></app>
Expand All @@ -50,7 +51,7 @@
<app name="foxitreader" install="false"></app>
<app name="adobereader" install="false"></app>
<!-- database -->
<app name="sqlitebrowser" install="true"></app>
<app name="sqlitebrowser" install="false"></app>

<toolsConfig>
<downloadParams params = "wget -O {target} {source}"></downloadParams>
Expand Down
67 changes: 40 additions & 27 deletions installTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,11 @@ def main():
createLogger()
# Windows Setup:
# - check and notify user to install
# - copy configuration to '%APPDATA%\Sublime Text 3'
if platform == 'Windows':
if(logger == None):
print("Logger object is null or undefined. Logging will not be done.");
logger.info("Windows OS detected")
print "Start work"
app_path = r"C:/Program Files/Sublime Text 3/subl.exe"
config_path = os.getenv('APPDATA') + '/Sublime Text 3'
if not Helpers.is_installed(app_path):
logger.info('Sublime not installed...')
# install_windows(app_path)
# config(config_path)
installOtherTools()
installChocolateyIfNotInstalled()
print "End Work. For more information please see the log file"
sys.exit(0)
else:
Expand All @@ -53,18 +45,18 @@ def main():
sys.exit(1)

# Windows installation instructions
def install_windows(app_path):
print('Installing Sublime')
def installChocolateyIfNotInstalled():
print('Will check if we need to install choco')
try:
if not Helpers.is_installed(['chocolatey']):
print('Chocolatey is not installed. Will attempt to install chocolatey')
logger.info('Chocolatey is not installed. Will attempt to install chocolatey')
os.system("support\\windows\\chocoinstall.cmd")
os.system("chocoinstall.cmd")
logger.info("chocolatey installed")
print("Please relaunch this script as an admin")
# p = subprocess.Popen(['choco', 'install', '-y', 'sublimetext3'],
# stdout=subprocess.PIPE, stderr=subprocess.PIPE)
os.system("choco install -y --force sublimetext3")
print('Installation complete...')
print('Chocolatey Installation complete. Please launch this exe again as an admin. Please note this is only required if choco is not installed. If it is already installed, this step is skipped...')
else:
installOtherTools()

except OSError as e:
print(e)
sys.exit(1)
Expand All @@ -86,11 +78,11 @@ def installOtherTools():
if(app.attrib["install"] == 'true'):
if "force" in app.attrib and app.attrib["force"]== 'true':
logger.info("App : {0} will be forcefully installed".format(appName));
# os.system("choco install -y --force {0}".format(appName))
os.system("choco install -y --force {0}".format(appName))
executeConfigurationInformation(appConfig, toolsConfig)
else:
logger.info("{0} will be installed".format(appName))
# os.system("choco install -y {0}".format(appName))
os.system("choco install -y {0}".format(appName))
executeConfigurationInformation(appConfig, toolsConfig)
else:
logger.info("{0} will NOT be installed".format(appName))
Expand Down Expand Up @@ -133,7 +125,7 @@ def handle(entry, config):
source = entry.attrib['source']
target = entry.attrib['target']
active = entry.attrib['active']
if(active):
if(active == 'true'):
sourcePathFileName = ntpath.basename(source)
logger.info("Will download the file : {0}".format(sourcePathFileName))
logger.info("Download Location : {0}".format(source))
Expand All @@ -151,6 +143,27 @@ def handle(entry, config):
logger.error(e)
pass

# FileDelete class
class runcommand():
@staticmethod
def handle(entry,config):
Helpers.logStatement("Run Command Module")
try:
logger.info("Run command module stated")
commandToRun = entry.text
active = entry.attrib['active']
logger.info("Command to run :{0}".format(commandToRun))
if(active == 'true' and commandToRun ):
os.system(commandToRun)
logger.info("Command : {0} was executed".format(commandToRun))
else:
logger.info("Please make sure that active flag is set to true. If it is set to true then check the command specified. The command that was supplied : {0}".format(commandToRun))
pass
except Exception as e:
logger.error(str(e))
print(str(e))
pass

# FileDelete class
class filedelete():
@staticmethod
Expand All @@ -161,7 +174,7 @@ def handle(entry,config):
fileToDelete = entry.text
active = entry.attrib['active']
logger.info("File to delete :{0}".format(fileToDelete))
if(active and os.path.exists(fileToDelete) and os.path.isfile(fileToDelete)):
if(active == 'true' and os.path.exists(fileToDelete) and os.path.isfile(fileToDelete)):
os.remove(fileToDelete)
logger.info("File : {0} was removed".format(fileToDelete))
else:
Expand All @@ -180,11 +193,11 @@ def handle(entry,config):
try:
directoryToMake = entry.text
active = entry.attrib['active']
if(active):
if(active == 'true'):
logger.info("Directory to make : {0}".format(directoryToMake))
if(os.path.exists(directoryToMake) and os.path.isdir(directoryToMake)):
logger.info("Directory : {0} already exists".format(directoryToMake));
return
logger.info("Directory : {0} already exists".format(directoryToMake));
return
else:
Helpers.make_dir(directoryToMake)
logger.info("Directory : {0} created successfully".format(directoryToMake))
Expand All @@ -203,7 +216,7 @@ def handle(entry,config):
Helpers.logStatement("Delete Directory Module")
try:
active = entry.attrib['active']
if(active):
if(active == 'true'):
directoryToDelete = entry.text
logger.info("Directory to delete : {0}".format(directoryToDelete))
if(os.path.exists(directoryToDelete) and os.path.isdir(directoryToDelete)):
Expand All @@ -227,7 +240,7 @@ def handle(entry,config):
try:
sourceFile = entry.attrib['sourceFile']
active = entry.attrib['active']
if(active and os.path.exists(sourceFile) and os.path.isfile(sourceFile)):
if(active == 'true' and os.path.exists(sourceFile) and os.path.isfile(sourceFile)):
targetDirectory = entry.attrib['targetDirectory']
newFileName = entry.attrib['newFileName']
if(newFileName is None):
Expand Down Expand Up @@ -266,7 +279,7 @@ def handle(entry,config):
sourceDirectory = entry.attrib['sourcedirectory']
targetDirectory = entry.attrib['targetdirectory']
active = entry.attrib['active']
if(active):
if(active == 'true'):
logger.info("source directory : {0}".format(sourceDirectory))
logger.info("target directory : {0}".format(targetDirectory))
Helpers.copytree(sourceDirectory, targetDirectory)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
console=["installTools.py"],
zipfile = None,
data_files=[("",
["installTools.config"]),
["installTools.config","chocoinstall.cmd"]),
],
name='InstallTools',
version='1.0.0',
Expand Down

0 comments on commit 08880a4

Please sign in to comment.