CONFIG_SYSTEM = '/etc/ga_frontend/ga_frontend.conf'
CONFIG_USER = os.path.expanduser('~/.ga_frontend.conf')
+#Disable or enable commandline arg parsing; disabled by default.
+DISABLE_CMDLINE = True
class FlowCellNotFound(Exception): pass
class WebError404(Exception): pass
+class DummyOptions:
+ """
+ Used when command line parsing is disabled; default
+ """
+ def __init__(self):
+ self.url = None
+ self.output_filepath = None
+ self.flowcell = None
+ self.genome_dir = None
class PreformattedDescriptionFormatter(IndentedHelpFormatter):
"""
returns a pre-setup optparser
"""
+ global DISABLE_CMDLINE
+
+ if DISABLE_CMDLINE:
+ return None
+
parser = OptionParser(formatter=PreformattedDescriptionFormatter())
parser.set_description('Retrieves eland config file from ga_frontend web frontend.')
parser.add_option("-f", "--flowcell",
action="store", type="string", dest="flowcell")
+
+ parser.add_option("-g", "--genome_dir",
+ action="store", type="string", dest="genome_dir")
#parser.set_default("url", "default")
parser.read([CONFIG_SYSTEM, CONFIG_USER])
if not parser.has_section('config_file_server'):
parser.add_section('config_file_server')
+ if not parser.has_section('local_setup'):
+ parser.add_section('local_setup')
return parser
cl_parser = constructOptionParser()
conf_parser = constructConfigParser()
- options, args = cl_parser.parse_args()
+ if cl_parser is None:
+ options = DummyOptions()
+ else:
+ options, args = cl_parser.parse_args()
if options.url is None:
if conf_parser.has_option('config_file_server', 'base_host_url'):
options.url = conf_parser.get('config_file_server', 'base_host_url')
+
+ if options.genome_dir is None:
+ if conf_parser.has_option('local_setup', 'genome_dir'):
+ options.genome_dir = conf_parser.get('local_setup', 'genome_dir')
print 'USING OPTIONS:'
print ' URL:', options.url
print ' OUT:', options.output_filepath
print ' FC:', options.flowcell
+ print 'GDIR:', options.genome_dir
print ''
return options