Skip to content
Browse files

modified setup.py

  • Loading branch information...
1 parent ad6159f commit 0eb1614aaaa9fba1e50e60c56bcdd946ee006280 @bastodian committed Nov 29, 2011
Showing with 27 additions and 32 deletions.
  1. +7 −9 BatchScriptsAndWrappers/OmWrapper.py
  2. +20 −23 setup.py
View
16 BatchScriptsAndWrappers/OmWrapper.py
@@ -20,10 +20,11 @@
Output file = path/to/taxon
'''
-import os, sys
+from sys import argv
+from os import system as bash
-infile=sys.argv[1]
-omrequest=sys.argv[2]
+infile=argv[1]
+omrequest=argv[2]
mytaxa=[]
linenum=0
@@ -35,9 +36,6 @@
if mylist[1] not in set(mytaxa):
mytaxa.append(mylist[1])
for taxon in mytaxa:
- replace='sed \'s/taxon/' + taxon + '/g\' ' + omrequest + ' > omnew.txt'
- os.system(replace)
- om='om_console omnew.txt'
- os.system(om)
- rm='rm omnew.txt'
- os.system(rm)
+ bash('sed \'s/taxon/' + taxon + '/g\' ' + omrequest + ' > omnew.txt')
+ bash('om_console omnew.txt')
+ bash('rm omnew.txt')
View
43 setup.py
@@ -2,7 +2,12 @@
from distutils.core import setup
from sys import exit
-import os, stat
+from os import chmod
+from os import listdir
+from os import getcwd
+from os import path
+from os import system as bash
+import stat
'''
Installation script that sets up NichePy and installs the modules it depends on.
@@ -38,11 +43,11 @@ def setupArg():
license='Python License',
)
-print("\nPlease choose your installation mode. Valid options are 1 or 2.\n\nIMPORTANT: Installation requires root privileges! Either change to the root account and run the script or use sudo.\n\n1 to make the scripts globally available. This will create symbolic links from the downloaded script files to /usr/bin.\n In addition the module containing functions for NichePy will be installed using Python's installer.\n\n2 to install in the same manner as 2 but also install the argparse module using Python's installer.\n This should only be necessary if you run Python3 < 3.2.\n\n")
+print("\nPlease choose your installation mode. Valid options are 1 or 2.\n\nIMPORTANT: Installation requires root privileges! Either change to the root account and run the script or use sudo.\n\n1 to make the scripts globally available. This will create symbolic links from the downloaded script files to /usr/bin.\n In addition the module containing functions for NichePy will be installed using Python's installer.\n\n2 to install in the same manner as 1 but also install the argparse module using Python's installer.\n This should only be necessary if you run Python3 < 3.2.\n\n")
### Ask for user input and create a list containing the python scripts to be installed
Install=input("\nPlease choose your installation mode: ")
-Scripts=[os.path.join(os.getcwd(),x) for x in os.listdir(os.getcwd()) if "getMetric" in x or "nicheBack" in x or "nicheIdent" in x]
+Scripts=[path.join(getcwd(),x) for x in listdir(getcwd()) if "getMetric" in x or "nicheBack" in x or "nicheIdent" in x]
if int(Install)==1 or int(Install)==2:
### Where should the scripts be linked to?
@@ -54,41 +59,33 @@ def setupArg():
if int(Install)==1:
print("\nMaking scripts executable.")
for file in Scripts:
- os.chmod(file, stat.S_IRWXU)
+ chmod(file, stat.S_IRWXU)
NewFile=file.split('.')[0]
- Move='mv ' + file + ' ' + NewFile
- os.system(Move)
- Link='ln -s ' + file.split('.')[0] + ' ' + ExecPath
- os.system(Link)
+ bash('mv ' + file + ' ' + NewFile)
+ bash('ln -s ' + file.split('.')[0] + ' ' + ExecPath)
print("\nInstalling module nichefunc, which contains functions for executable NichePy scripts.")
setupFunc()
- Rm='rm ' + 'nichefunc.py'
- os.system(Rm)
- Rm='rm ' + 'argparse.py'
- os.system(Rm)
+ bash('rm ' + 'nichefunc.py')
+ bash('rm ' + 'argparse.py')
print("\nInstallation complete. Scripts can be called by issuing the following commands:")
- for i in os.listdir(os.getcwd()):
+ for i in listdir(getcwd()):
if "getMetric" in i or "nicheBack" in i or "nicheIdent" in i:
print("\n",i,"-h for brief guide of the script's usage")
### Install option no 2
else:
print("\nMaking scripts executable.")
for file in Scripts:
- os.chmod(file, stat.S_IRWXU)
+ chmod(file, stat.S_IRWXU)
NewFile=file.split('.')[0]
- Move='mv ' + file + ' ' + NewFile
- os.system(Move)
- Link='ln -s ' + file.split('.')[0] + ' ' + ExecPath
- os.system(Link)
+ bash('mv ' + file + ' ' + NewFile)
+ bash('ln -s ' + file.split('.')[0] + ' ' + ExecPath)
print("\nInstalling module nichefunc, which contains functions for executable NichePy scripts.")
setupFunc()
- Rm='rm ' + 'nichefunc.py'
- os.system(Rm)
+ bash('rm ' + 'nichefunc.py')
setupArg()
- Rm='rm ' + 'argparse.py'
- os.system(Rm)
+ bash('rm ' + 'argparse.py')
print("\nInstallation complete. Scripts can be called by issuing the following commands:")
- for i in os.listdir(os.getcwd()):
+ for i in listdir(getcwd()):
if "getMetric" in i or "nicheBack" in i or "nicheIdent" in i:
print("\n",i,"-h for brief guide of the script's usage")
print("\nFor more details please refer to the manual of NichePy.\n")

0 comments on commit 0eb1614

Please sign in to comment.
Something went wrong with that request. Please try again.