started implementation of a makePyLoT routine capable of building and installing PyLoT to a desired directory
This commit is contained in:
parent
1702051d8f
commit
c7f09988e5
57
makePyLoT.py
57
makePyLoT.py
@ -33,7 +33,7 @@ __version__ = 0.1
|
|||||||
__date__ = '2014-11-26'
|
__date__ = '2014-11-26'
|
||||||
__updated__ = '2014-11-26'
|
__updated__ = '2014-11-26'
|
||||||
|
|
||||||
DEBUG = 1
|
DEBUG = 0
|
||||||
TESTRUN = 0
|
TESTRUN = 0
|
||||||
PROFILE = 0
|
PROFILE = 0
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ def main(argv=None): # IGNORE:C0111
|
|||||||
program_name = os.path.basename(sys.argv[0])
|
program_name = os.path.basename(sys.argv[0])
|
||||||
program_version = "v%s" % __version__
|
program_version = "v%s" % __version__
|
||||||
program_build_date = str(__updated__)
|
program_build_date = str(__updated__)
|
||||||
program_version_message = '%%(prog)s %s (%s)' % (program_version, program_build_date)
|
program_version_message = '%makePyLoT %s (%s)' % (program_version, program_build_date)
|
||||||
program_shortdesc = __import__('__main__').__doc__.split("\n")[1]
|
program_shortdesc = __import__('__main__').__doc__.split("\n")[1]
|
||||||
program_license = '''%s
|
program_license = '''%s
|
||||||
|
|
||||||
@ -77,38 +77,35 @@ USAGE
|
|||||||
try:
|
try:
|
||||||
# Setup argument parser
|
# Setup argument parser
|
||||||
parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter)
|
parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter)
|
||||||
parser.add_argument("-r", "--recursive", dest="recurse", action="store_true", help="recurse into subfolders [default: %(default)s]")
|
parser.add_argument("-b", "--build", dest="build", action="store_true", help="build PyLoT")
|
||||||
parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]")
|
parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level")
|
||||||
parser.add_argument("-i", "--include", dest="include", help="only include paths matching this regex pattern. Note: exclude is given preference over include. [default: %(default)s]", metavar="RE" )
|
parser.add_argument("-i", "--install", dest="install", action="store_true", help="install PyLoT on the system")
|
||||||
parser.add_argument("-e", "--exclude", dest="exclude", help="exclude paths matching this regex pattern. [default: %(default)s]", metavar="RE" )
|
parser.add_argument("-d", "--directory", dest="directory", help="installation directory", metavar="RE" )
|
||||||
parser.add_argument('-V', '--version', action='version', version=program_version_message)
|
parser.add_argument('-V', '--version', action='version', version=program_version_message)
|
||||||
parser.add_argument(dest="paths", help="paths to folder(s) with source file(s) [default: %(default)s]", metavar="path", nargs='+')
|
|
||||||
|
|
||||||
# Process arguments
|
# Process arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
paths = args.paths
|
|
||||||
verbose = args.verbose
|
verbose = args.verbose
|
||||||
recurse = args.recurse
|
build = args.build
|
||||||
inpat = args.include
|
install = args.install
|
||||||
expat = args.exclude
|
directory = args.directory
|
||||||
|
|
||||||
if verbose > 0:
|
if verbose > 0:
|
||||||
print("Verbose mode on")
|
print("Verbose mode on")
|
||||||
if recurse:
|
if install and not directory:
|
||||||
print("Recursive mode on")
|
raise CLIError("trying to install without destination; please specify an installation directory")
|
||||||
else:
|
if build and install:
|
||||||
print("Recursive mode off")
|
print("Building and installing PyLoT ...")
|
||||||
|
buildPyLoT()
|
||||||
if inpat and expat and inpat == expat:
|
installPyLoT()
|
||||||
raise CLIError("include and exclude pattern are equal! Nothing will be processed.")
|
elif build and not install:
|
||||||
|
print("Building PyLoT without installing! Please wait ...")
|
||||||
for inpath in paths:
|
buildPyLoT()
|
||||||
### do something with inpath ###
|
cleanUp()
|
||||||
print(inpath)
|
|
||||||
return 0
|
return 0
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
### handle keyboard interrupt ###
|
cleanUp()
|
||||||
return 0
|
return 0
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if DEBUG or TESTRUN:
|
if DEBUG or TESTRUN:
|
||||||
@ -118,11 +115,23 @@ USAGE
|
|||||||
sys.stderr.write(indent + " for help use --help")
|
sys.stderr.write(indent + " for help use --help")
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
def buildPyLoT():
|
||||||
|
if sys.platform.startswith('win' or 'microsoft'):
|
||||||
|
raise CLIError("building on Windows system not tested yet; implementation pending")
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def installPyLoT():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cleanUp():
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
sys.argv.append("-h")
|
sys.argv.append("-h")
|
||||||
sys.argv.append("-v")
|
sys.argv.append("-v")
|
||||||
sys.argv.append("-r")
|
|
||||||
if TESTRUN:
|
if TESTRUN:
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
Loading…
Reference in New Issue
Block a user