Example #1
0
def main():
    import sys
    import os
    h = 6.6260689633e-34
    c = 299792458
    electron  = 1.60217653141e-19

    def toenergy(wave):
        energy = (h*c)/(float(wave)*1e-10*electron)
        return energy

    def towave(energy):
        wave = (h*c)/(float(energy)*electron)
        return wave

    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("--energy","-e",dest="energy",metavar="energy ev",help="Energy in ev")
    parser.add_option("--wave","-w",dest="wave",metavar="wave A",help="wavelenbth in Angstrom")
    (options,spillover) = parser.parse_args()


    if options.energy is not None:
        energy = options.energy
        wave = towave(energy)
        print "The input %s energy in ev corresponds to %s wavelength" % ( energy , wave)


    elif options.wave is not None:
        wave = sys.argv[2]
        energy = toenergy(wave)
        print "The input %s wavelength corressponds to %s ev " % (wave,energy)
    else:
        parser.print_help()
        exit()
Example #2
0
def parseOptions():

    #setup command line parser
    '''This is out of date, needs to be updated to reflect new additions'''
    parser = op.OptionParser(
        usage="Usage: %prog [options] XMLFILE",
        version="%prog 1.0",
        description=r"Reads in the XMLFILE which specifies " +
        "how the light curve is to be made. see light_curve_reference.xml for a "
        +
        "template xml file to be used with this script. Found in the SPHERLS "
        + "directory docs/templateXML.")
    parser.add_option(
        "--write-diagnostics",
        dest="writeDiagnostics",
        action="store_true",
        help=
        "If set it will write out Logg,g,accel,T_eff,BC to the output file in"
        +
        " that order in addition to the time and mag in the first and second "
        + "columns",
        default=False)
    parser.add_option(
        "-d",
        dest="double",
        action="store_true",
        help="If set it will double the data in the light curve for easier " +
        "viewing of the light curve shape.",
        default=False)

    make_profiles.addParserOptions(parser)

    #parse command line options
    return parser.parse_args()
Example #3
0
def main():
    parser = optparse.OptionParser(usage='Usage: %prog [options] filename')
    parser.add_option('-s', '--source', dest='source', default=DEFAULT_SOURCE,
                      help='Source path. Default: ' + DEFAULT_SOURCE)
    parser.add_option('-d', '--destination', dest='destination',
                      default=DEFAULT_DESTINATION,
                      help='Destination path. Default: ' + DEFAULT_DESTINATION)
    (options, args) = parser.parse_args()
    process(options.source, options.destination)
Example #4
0
 def options(self, parser, env):
     super(FreshenNosePlugin, self).options(parser, env)
     
     parser.add_option('--tags', action='store',
                       dest='tags',
                       default=env.get('NOSE_FRESHEN_TAGS'),
                       help="Run only those scenarios and features which "
                            "match the given tags. Should be a comma-separated "
                            "list. Each tag can be prefixed with a ~ to negate "
                            "[NOSE_FRESHEN_TAGS]")
Example #5
0
def main():
    global verbose
    global ssl_location
    global revocation

    if int(os.getuid()) > 0:
        print "[-] You need to be root for this."
        sys.exit(1)

    # command line options
    parser = OptionParser()
    parser.add_option("-a",
                      help="Adapter to sniff on",
                      action="store",
                      default="eth0",
                      dest="adapter")
    parser.add_option('-v',
                      help="Dump certificate information",
                      action="store_true",
                      default=False,
                      dest="verbose")
    parser.add_option('-s',
                      help="Specify a different SSL cert location",
                      action="store",
                      default='/etc/ssl/certs',
                      dest='certFile')
    parser.add_option('-p',
                      help="Specify a port (default: 443)",
                      action="store",
                      default=443,
                      dest="port")
    parser.add_option('-r',
                      help="Specify a CRL file for lookup; give full path",
                      action="store",
                      default=None,
                      dest="revocation")

    (options, args) = parser.parse_args()
    adapter = options.adapter
    verbose = options.verbose
    port = options.port
    revocation = options.revocation

    # validate the ssl cert folder
    if os.path.isdir(options.certFile):
        ssl_location = options.certFile
    else:
        ssl_location = '/etc/ssl/certs/'

    try:
        print "[+] Beginning sniffer on adapter '{0}' port {1}".format(
            adapter, port)
        sniff(filter="tcp and port %s" % port, iface=adapter, prn=validate)
    except KeyboardInterrupt, k:
        print "\n[!] Closing down..."
Example #6
0
def read_option():

    usage = "launch gp_job"
    parser = optparse.OptionParser(usage=usage)

    parser.add_option("--rep",
                      "-r",
                      dest="rep",
                      help="dir input/output",
                      default=100)

    option, args = parser.parse_args()

    return option
Example #7
0
def option():
    usage = "usage: %prog [options] arg"
    parser = OptionParser(usage)

    parser.add_option("-f",
                      "--file",
                      dest="filename",
                      help="file with download links")
    parser.add_option("-t",
                      "--thread",
                      dest="thread_number",
                      help="How much files download in one time",
                      default=2)
    parser.add_option("-k", "--key", dest="key", help="Key for premka")
    parser.add_option("-d",
                      "--no-delete",
                      action="store_false",
                      dest="no_delete",
                      help="Dont delete exists links on premka",
                      default=True)
    (options, args) = parser.parse_args()
    if not options.filename:
        parser.error('File name option is required')
    if not options.key:
        parser.error('Premka key is required')
    return options
Example #8
0
def read_option():

    usage = "launch mcmc for shear fitting of des y1"
    parser = optparse.OptionParser(usage=usage)

    parser.add_option("--rep", "-r", dest="rep", help="dir output", default='')
    parser.add_option("--nwalkers",
                      "-w",
                      dest="nwalkers",
                      help="number of walkers",
                      default='33')
    parser.add_option("--nsteps",
                      "-n",
                      dest="nsteps",
                      help="number of steps",
                      default='2')
    parser.add_option("--seed",
                      "-s",
                      dest="seed",
                      help="seed of the generator",
                      default='42')

    option, args = parser.parse_args()

    return option
Example #9
0
File: mess.py Project: nekobon/mess
def handle_user_params():
	"""
	Handles user parameters using python's built-in optparse module.

	@rtype: dict
	@return: The dictionary of the user parameters with the below elements,
				- 'errorFile', default value is 'errors.json'
				- 'inputFile', default value is 'quipsim.txt'
	"""
	parser = OptionParser('Usage: mcchp.py [options]')
	parser.add_option("-e", "--error", dest="errorFile", default='sample_errors.json',
			help="Specify a json file wit error rates (default = sample_errors.json)", metavar="FILE")
	parser.add_option("-i", "--input", dest="inputFile", default='sample_input.txt',
			help="Specify a QUIPSIM output file for the input circuit (default = sample_input.txt)", 
			metavar="FILE")
	(options, args) = parser.parse_args()
	return options
Example #10
0
def parse_args():
    """parse_args parses sys.argv for wiki2centrality."""
    # Help Menu
    parser = optparse.OptionParser(usage='%prog [options] title')
    parser.add_option('-r', '--remove',
                      action='store_false', dest='remove', default=True,
                      help='remove mass deletions')
    parser.add_option('-c', '--centrality',
                      type='str', dest='ctype', default='closeness',
                      help='type of centrality: closeness, out_degree, betweenness',
                      metavar='CTYPE')

    (opts, args) = parser.parse_args()

    # Parser Errors
    if len(args) != 1:
        parser.error('incorrect number of arguments')

    wiki2centrality(args[0], remove=opts.remove, ctype=opts.ctype)
Example #11
0
def parseOptions():

    #setup command line parser
    parser = op.OptionParser(
        usage="Usage: %prog [options] XMLFILE",
        version="%prog 1.0",
        description=r"Creates one or more HDF files. XMLFILE " +
        "gives all the settings needed. For an example of a configuration file see"
        + " make_hdf_reference.xml under docs/templateXML.")

    parser.add_option("-k",
                      "--keep",
                      action="store_true",
                      dest="keep",
                      help="Keeps distributed binary files [default].",
                      default=True)
    parser.add_option("-r",
                      "--remove",
                      action="store_false",
                      dest="keep",
                      help="Removes distributed binary files")
    parser.add_option(
        "--remake-bins",
        action="store_true",
        dest="remakeBins",
        help="Will remake binaries even if they already exist. [not default].",
        default=False)

    #parse command line options
    (options, args) = parser.parse_args()
    if len(args) == 0:
        raise Exception("must supply an xml configure file")
    return (options, args)
Example #12
0
def main():
    global verbose
    global ssl_location
    global revocation

    if int(os.getuid()) > 0:
        print "[-] You need to be root for this."
        sys.exit(1)

        # command line options
    parser = OptionParser()
    parser.add_option("-a", help="Adapter to sniff on", action="store", default="eth0", dest="adapter")
    parser.add_option("-v", help="Dump certificate information", action="store_true", default=False, dest="verbose")
    parser.add_option(
        "-s", help="Specify a different SSL cert location", action="store", default="/etc/ssl/certs", dest="certFile"
    )
    parser.add_option("-p", help="Specify a port (default: 443)", action="store", default=443, dest="port")
    parser.add_option(
        "-r", help="Specify a CRL file for lookup; give full path", action="store", default=None, dest="revocation"
    )

    (options, args) = parser.parse_args()
    adapter = options.adapter
    verbose = options.verbose
    port = options.port
    revocation = options.revocation

    # validate the ssl cert folder
    if os.path.isdir(options.certFile):
        ssl_location = options.certFile
    else:
        ssl_location = "/etc/ssl/certs/"

    try:
        print "[+] Beginning sniffer on adapter '{0}' port {1}".format(adapter, port)
        sniff(filter="tcp and port %s" % port, iface=adapter, prn=validate)
    except KeyboardInterrupt, k:
        print "\n[!] Closing down..."
Example #13
0
def main():
    parser = OptionParser()
    parser.set_usage(parser.get_usage().rstrip())
    parser.add_option("-l", "-L", "--load", action="append_const", const="LOAD", dest="oper", help = "load data")
    parser.add_option("-r", "-R", "--run", action="append_const", const="RUN", dest="oper", help = "run test")
    parser.add_option("-c", "--configure-file", dest="configFile", type="string", default='run_blogbench.cfg'
        , help = "path of configure file, default is 'run_blogbench.cfg'")
    (options, args) = parser.parse_args()

    testWorker = Tester()
    testWorker.run(options.configFile, options.oper)
Example #14
0
def _parse_args():
    """
    Parses the command line arguments.

    @return: Tuple with options and (positional) arguments.
    @rtype: tuple
    """
    parser = optparse.OptionParser(usage="", description="")
    parser.add_option("-o", dest="outfile", default=None, help="File to write to")
    parser.add_option("-w", dest="write_format", default="pidgin", help="Write format. [default: %default]")
    parser.add_option("-r", dest="read_format", default="adium", help="Read format. [default: %default]")

    return parser.parse_args()
Example #15
0
        if pn is None or not os.path.exists(pn):
            return 0
        return os.stat(pn).st_size

    for fs in fsop.get_all_fs():
        one = _get_merged_file(fs)
        fss = _get_fss_file(fs)

        print "%-10s %10s B %10s B" % (fs, _get_size(one), _get_size(fss))


if __name__ == '__main__':
    utils.install_pdb()

    parser = optparse.OptionParser()
    parser.add_option("--linux", help="Linux kernel", default=LINUX)
    parser.add_option("--clang", help="Clang path", default=CLANG)
    parser.add_option("--outdir", help="Clang output dir", default="/tmp")
    (opts, args) = parser.parse_args()

    def __print_usage(note):
        print(note)
        for (cmd, func) in get_all_cmds():
            print("> %-20s: %s" % (cmd, func.__doc__))
        exit(0)

    if len(args) == 0:
        __print_usage("Need to specify a command")

    cmd = args[0]
    if get_cmd(cmd) is None:
Example #16
0
import optparse
import parser
import zipfile
from threading import Thread


def extract_zip(zfile, password):
    try:
        zfile.extractall(pwd=password)
        print("[+] Password found: " + password + '\n')
    except:
        pass


if __name__ == '__main__':
    parser = optparse.OptionParser("usage %prog " + \
                                   "-f <zipfile> -d <dicctionary>")
    parser.add_option('-f', dest='zname', type='string', \
                      help='specify zip file')
    parser.add_option('-d', dest='dname', type='string', \
                      help='specify dictionary file')
    (options, arg) = parser.parse_args()
    print('ell')
    if (options.zname is None) or (options.dname is None):
        print(parser.usage)
        exit(0)
    else:
        zname = options.zname
        dname = options.dname
Example #17
0
File: oopsc.py Project: Panke/oopsc
def generate_parser():
    usage = "%prog [options] source [dest]"
    parser = OptionParser(usage=usage)

    parser.add_option("-c", "--print-context", dest="p_context",
                      action="store_true", default=False,
                      help='print the outcome of the context analysis')

    parser.add_option('--heapsize', dest="heapsize", action='store',
                      type='int', default=100, metavar='LONGWORDS',
                      help='set the size of the heap to x LONGWORDS (4 Byte)')

    parser.add_option('--stacksize', dest='stacksize', action='store',
                      type='int', default=50, metavar='LONGWORDS',
                      help='set the size of the stack to x LONDWORDS (4 Byte)')

    parser.add_option('-i', '--print-identifier', dest='p_identifier',
                      action='store_true', default=False, help='print the '
                      'identifier map')

    parser.add_option('-I', '--print-lexical', dest='p_lexical',
                      action='store_true', default=False,
                      help='print the outcome of the lexical analysis')

    parser.add_option('-s', '--print-syntax', dest='p_syntax',
                      action='store_true', default=False,
                      help='print the outcome of the syntax analysis')

    return parser
Example #18
0
def main():
    import os
    import json
    import pickle
    import re
    from optparse import OptionParser

    parser = OptionParser()
    parser.add_option('-q',
                      '--ip-api',
                      dest='ip_api',
                      default='http://127.0.0.1:8080',
                      help='HTTP API to retrieve IP info.')
    parser.add_option('-f',
                      '--file',
                      default='route.pickle',
                      help='Use the pickled routes')
    parser.add_option('-u',
                      '--update',
                      action="store_true",
                      default=False,
                      help='Update routes')
    parser.add_option('--source-network',
                      dest='source_network',
                      action='append',
                      help='Regex of source network pattern')
    parser.add_option('--target-network',
                      dest='target_network',
                      action='append',
                      help='Regex of target network pattern')

    (options, args) = parser.parse_args()

    logging.basicConfig(
        level=logging.INFO,
        format=
        '[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d] %(message)s')

    if not args:
        import explore
        args = explore.targets

    ip_parser = lambda ip: parse_ip(options.ip_api, ip)

    source_network = []
    for pattern in options.source_network:
        logging.info('Using source pattern: ' + pattern)
        source_network.append(re.compile(pattern, re.IGNORECASE))

    target_network = []
    for pattern in options.target_network:
        logging.info('Using target pattern: ' + pattern)
        target_network.append(re.compile(pattern, re.IGNORECASE))

    routes = []
    if not options.update:
        try:
            routes = pickle.load(open(options.file, 'rb'))
        except Exception as e:
            logging.error(e, exc_info=True)

    if not routes:
        logging.info("Fetching routes.")
        for ip in args:
            for route in get_routes(ip, ip_parser):
                routes.append(route)

        logging.info('Dumping routes into {}'.format(options.file))
        tmp_filename = options.file + '.tmp'
        tmp = open(tmp_filename, 'wb')
        pickle.dump(routes, tmp, protocol=2)
        os.rename(tmp_filename, options.file)

    geo_json = GeoJSON()
    for route in routes:
        if not match(source_network, route[1]) or not match(
                target_network, route[3]):
            continue

        geo_json.add_route(*route)

    print(json.dumps(geo_json.to_object()))
Example #19
0
import parser
from scorer import scorer
from collections import Counter
from sklearn.svm import SVC
from sklearn import cross_validation
from sklearn import grid_search
from stacking_create_training_set import stacking_create_training_set
import xml.etree.ElementTree as ET


#defining the options of the script

#INPUTS: -i duke_config.xml, -N number_of_configurations, -a amplitude_of_perturbation, -g gold_standard_name

parser = optparse.OptionParser()
parser.add_option('-i','--input', dest = 'file_name', help = 'file_name')
parser.add_option('-N','--number', dest = 'N', help = 'number of classifiers',type = int)
parser.add_option('-a','--amplitude', dest = 'a', help = 'amplitude of perturbation',type = float)
parser.add_option('-g','--gold', dest = 'gold_standard_name', help = 'gold_standard_name')

(options, args) = parser.parse_args()

if options.file_name is None:
   options.file_name = raw_input('Enter file name:')

if options.N is None:
    options.N = raw_input('Enter number of classifiers:')

if options.a is None:
    options.a = 0.05 #default to 0.05
Example #20
0
        # Summe == 28 d.h. alle Kapitel haben Text
        if sum == 28:
            cmd  = "update `%s`.`%s` " % (databaseList, table)
            cmd += "set Apg = 1 where ms = %s " % (ms[0])
        else:
            cmd  = "update `%s`.`%s` " % (databaseList, table)
            cmd += "set Apg = 0 where ms = %s " % (ms[0])
        cursor.execute(cmd)
    cursor.close()
    dba.close()

if __name__ == "__main__":
    import sys
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-r", "--recreate", dest="recreate", action="store_true", help="Recreate ECM_Acts_Mss.ActsMsList_2")
    parser.add_option("-d", "--database", dest="database", help="Database containing systematic lacunae list")
    parser.add_option("-t", "--table", dest="table", help="Giving name systematic lacunae list")
    parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="Verbose mode")
    (opts, args) = parser.parse_args()
    parser.destroy()
    if opts.database is None:
        print "Error: Database name is missing!"
        print "See python %s -h" % sys.argv[0]
        sys.exit(1)
    if opts.table is None:
        print "Error: Table name is missing!"
        print "See python %s -h" % sys.argv[0]
        sys.exit(1)
    if opts.recreate is None:
        main_8(opts.database, opts.table, opts.verbose)
Example #21
0
def main(name, version, datatype):
    log.info("------------- %s %s -----------------", name, version)
    usage = """usage: python %prog [options] <foldername>

    PartitionFinder and PartitionFinderProtein are designed to discover optimal 
    partitioning schemes for nucleotide and amino acid sequence alignments. 
    They are also useful for finding the best model of sequence evolution for datasets.

    The Input: <foldername>: the full path to a folder containing:
        - A configuration file (partition_finder.cfg)
        - A nucleotide/aa alignment in Phylip format
    Take a look at the included 'example' folder for more details.

    The Output: A file in the same directory as the .cfg file, named
    'analysis' This file contains information on the best
    partitioning scheme, and the best model for each partiiton

    Usage Examples: 
        >python %prog example
        Analyse what is in the 'example' sub-folder in the current folder.

        >python %prog -v example
        Analyse what is in the 'example' sub-folder in the current folder, but
        show all the debug output

        >python %prog -c ~/data/frogs
        Check the configuration files in the folder data/frogs in the current
        user's home folder.

        >python %prog --force-restart ~/data/frogs
        Deletes any data produced by the previous runs (which is in
        ~/data/frogs/output) and starts afresh
    """
    parser = OptionParser(usage)
    parser.add_option(
        "-v", "--verbose",
        action="store_true", dest="verbose",
        help="show verbose (debug) output")
    parser.add_option(
        "-c", "--check-only",
        action="store_true", dest="check_only",
        help="just check the configuration files, don't do any processing")
    parser.add_option(
        "--force-restart",
        action="store_true", dest="force_restart",
        help="delete all previous output and start afresh (!)")
    parser.add_option(
        "-p", "--processes", 
        type="int", dest="processes", default=-1, metavar="N",
        help="Number of concurrent processes to use."
        " Use -1 to match the number of cpus on the machine."
        " The default is to use -1.")
    parser.add_option(
        "--show-python-exceptions",
        action="store_true", dest="show_python_exceptions",
        help="If errors occur, print the python exceptions")
    parser.add_option(
        "--save-phyml",
        action="store_true", dest="save_phyml",
        help="save all of the phyml output. This can take a lot of space(!)")
    parser.add_option(
        "--dump-results",
        action="store_true", dest="dump_results",
        help="Dump all results to a binary file. "
        "This is only of use for testing purposes.")
    parser.add_option(
        "--compare-results",
        action="store_true", dest="compare_results",
        help="Compare the results to previously dumped binary results. "
        "This is only of use for testing purposes.")
    
    options, args = parser.parse_args()

    # Error checking
    if options.dump_results and options.compare_results:
        log.error("You can't dump and compare results in one run!")
        log.error("Please select just one of these")

    # We should have one argument: the folder to read the configuration from
    if not args:
        # Otherwise exit, printing the help
        parser.print_help()
        return 2

    #before we start, let's check the python version is above 2.7 but lower than 3.0    
    python_version = float("%d.%d" %(sys.version_info[0], sys.version_info[1]))

    log.info("You have Python version %.1f" %python_version)

    if python_version<2.7:
        log.error("Your Python version is %.1f, but this program requires Python 2.7. "
        "Please upgrade to version 2.7 by visiting www.python.org/getit, or by following"
        " the instructions in the PartitionFinder manual." % python_version)
        return 0

    if python_version>3.0:
        log.warning("Your Python version is %.1f. This program was not built to run with "
        "version 3 or higher. To guarantee success, please use Python 2.7.x" % python_version)

    # Load, using the first argument as the folder
    try:
        cfg = config.Configuration(datatype)
        cfg.load_base_path(args[0])
                
        if options.check_only:
            log.info("Exiting without processing (because of the -c/--check-only option ...")
        else:

            # For now, we just turn on debugging for the analysis section
            # For finer grain, see the logging.cfg file
            if options.verbose:
                logging.getLogger('analysis').setLevel(logging.DEBUG)
                logging.getLogger('analysis_method').setLevel(logging.DEBUG)

            # Now try processing everything....
            method = analysis_method.choose_method(cfg.search)
            rpt = reporter.TextReporter(cfg)
            anal = method(cfg, rpt, 
                          options.force_restart, 
                          options.save_phyml,
                          options.processes)
            results = anal.analyse()

            if options.dump_results:
                results.dump(cfg)
            elif options.compare_results:
                results.compare(cfg)
            
        # Successful exit
        log.info("Processing complete.")

        return 0

    except util.PartitionFinderError:
        log.error("Failed to run. See previous errors.")
        if options.show_python_exceptions:
            raise

    except KeyboardInterrupt:
        log.error("User interrupted the Program")

    return 1
Example #22
0
def parse_options(args=sys.argv):
    parser = optparse.OptionParser()

    #
    # Global options.
    #
    parser.add_option('-l', '--loglevel', action='store', default='WARNING',
        choices=['DEBUG', 'INFO', 'WARNING', 'ERROR'],
        help="""Logging level. Choices: DEBUG, INFO, WARNING, ERROR.
            [default: WARNING]""")

    #
    # Options for compilation (joosc).
    #
    stage_opts = [
        'scanner',
        'parser',
        'weeder',
        'ast',
        'hierarchy',
        'name',
        'typecheck',
        'reachability',
        'codegen',
        'asm',
        'end'
    ]
    parser.add_option('-s', '--stage', action='store', dest='stage',
        default='end', choices=stage_opts,
        help="Stage of compiler to run \"up to\" before terminating.")

    parser.add_option('-i', '--include_stdlib', action='store_true',
        default=False,
        dest='include_stdlib', help="Include all stdlib files in compilation")

    parser.add_option('--print_stdlib', action='store_true',
        dest='print_stdlib',
        help="""Override default hiding of output printout for stdlib files.
            Only has any effect if -s and -i are specified.""")

    parser.add_option('-d', '--directory_crawl', action='store_true',
        dest='directory_crawl', default=True,
        help="Recursively crawl directories for compilation units")

    parser.add_option('-c', '--clean_output', action='store_true',
        dest='clean_output', default=False,
        help="Clean the output directory before codegen.")

    #
    # Options for testing.
    #

    parser.add_option('-t', '--test', action='store', dest='test',
        help="Run tests under the specified directory under assignment_testcases.")

    parser.add_option('--show_errors', action='store_true',
        dest='show_errors',
        help="Disable stderr printout suppression. Only usable during tests.")

    return parser.parse_args()
Example #23
0
        if pn is None or not os.path.exists(pn):
            return 0
        return os.stat(pn).st_size

    for fs in fsop.get_all_fs():
        one = _get_merged_file(fs)
        fss = _get_fss_file(fs)

        print "%-10s %10s B %10s B" % (fs, _get_size(one), _get_size(fss))


if __name__ == '__main__':
    utils.install_pdb()

    parser = optparse.OptionParser()
    parser.add_option("--linux", help="Linux kernel", default=LINUX)
    parser.add_option("--clang", help="Clang path", default=CLANG)
    parser.add_option("--outdir", help="Clang output dir", default="/tmp")
    parser.add_option("--type", help="Juxta's analysis type: fs, ieee80211 ...etc", default=TYPE)

    (opts, args) = parser.parse_args()

    def __print_usage(note):
        print(note)
        for (cmd, func) in get_all_cmds():
            print("> %-20s: %s" % (cmd, func.__doc__))
        exit(0)

    if len(args) == 0:
        __print_usage("Need to specify a command")
Example #24
0
extensions = {
    'writer': '.ast',
    'pascal': '.pas',
    'java': '.java',
    'python': '.py',
    'scheme': '.scm',
    'ada': '.ada',
}

usage = 'usage: %prog [options] ccfiles'
version = '%prog 1.0'

parser = optparse.OptionParser(usage=usage, version=version)
parser.add_option('-w',
                  '--writer',
                  action='store_true',
                  dest='writer',
                  default=False,
                  help='write the AST')
parser.add_option('-p',
                  '--pascal',
                  action='store_true',
                  dest='pascal',
                  default=False,
                  help='compile to Pascal')
parser.add_option('-j',
                  '--java',
                  action='store_true',
                  dest='java',
                  default=False,
                  help='compile to Java')
parser.add_option('-y',
Example #25
0
interactive
game
on
a
smaller
board, zoomed in
"""

import parser

parser = OptionParser(usageStr)

parser.add_option('-n',
                  '--numGames',
                  dest='numGames',
                  type='int',
                  help=default('the number of GAMES to play'),
                  metavar='GAMES',
                  default=1)
parser.add_option(
    '-l',
    '--layout',
    dest='layout',
    help=default('the LAYOUT_FILE from which to load the map layout'),
    metavar='LAYOUT_FILE',
    default='mediumClassic')
parser.add_option(
    '-p',
    '--pacman',
    dest='pacman',
    help=default('the agent TYPE in the pacmanAgents module to use'),
Example #26
0
from dirScan import *
from CIPscan import *
from optparse import OptionParser

if __name__ == '__main__':
    print('''
    By cteen  Ver:1.0
 __    __     _     __                                 
/ / /\ \ \___| |__ / _\ ___ __ _ _ __  _ __   ___ _ __ 
\ \/  \/ / _ \ '_ \\ \ / __/ _` | '_ \| '_ \ / _ \ '__|
 \  /\  /  __/ |_) |\ \ (_| (_| | | | | | | |  __/ |   
  \/  \/ \___|_.__/\__/\___\__,_|_| |_|_| |_|\___|_|   

    ''')
    parser = OptionParser()
    parser.add_option("-u", "--url", dest="url", help="target url for scan")
    parser.add_option("-f", "--file", dest="ext", help="target url ext")
    parser.add_option("-i", "--ip", dest="ip", help="target ip for scan C")
    parser.add_option("-t",
                      "--thread",
                      dest="count",
                      type="int",
                      default=1,
                      help="count of scan thread")
    parser.add_option("-d",
                      "--domain",
                      dest="domain",
                      help="target domain for scan")
    (option, args) = parser.parse_args()
    if option.url and option.ext:
        print("[+]Scan for %s will start ! Filetype is %s..." %
Example #27
0
    actions = {
            'parseprint' : printParseTreeFromFile,
            'astprint'   : printAstFromFile,
            'interp'     : interpretFile
            }

    from optparse import OptionParser
    parser = OptionParser(
            usage="""
python %prog action [-o outputfile] pl0sourcefile
Action is one of
    parseprint      - parse and print the parse tree,
    astprint        - parse, generate the AST then print the AST,
    interp          - parse, generate the AST then interpret the AST""")
    parser.add_option('-o', '--outputfile',
                      action='store',
                      dest='outputfile',
                      help='Output file.')
    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.error('wrong number of arguments.')

    action = args[0]
    infile = args[1]
    if action in ('parseprint', 'astprint', 'interp') and len(args) == 2:
        if action == 'x86asm' or action == 'c--':
            # check -o option
            if hasattr(options, 'outputfile') and options.outputfile:
                actions[action](infile, options.outputfile)
            else:
                parser.error('Missing -o option.')
Example #28
0
def start_server():
    parser = OptionParser(usage="usage: %prog [options]", version="%prog 1.0")
    parser.add_option("--host",
                      default='',
                      type='string',
                      action="store",
                      dest="host",
                      help="hostname (localhost)")
    parser.add_option("--port",
                      default=9001,
                      type='int',
                      action="store",
                      dest="port",
                      help="port (9001)")
    parser.add_option("--example",
                      default='echo',
                      type='string',
                      action="store",
                      dest="example",
                      help="echo, chat")
    parser.add_option("--ssl",
                      default=0,
                      type='int',
                      action="store",
                      dest="ssl",
                      help="ssl (1: on, 0: off (default))")
    parser.add_option("--cert",
                      default='./cert.pem',
                      type='string',
                      action="store",
                      dest="cert",
                      help="cert (./cert.pem)")
    parser.add_option("--ver",
                      default=ssl.PROTOCOL_TLSv1,
                      type=int,
                      action="store",
                      dest="ver",
                      help="ssl version")

    (options, args) = parser.parse_args()

    os.system("rm ./unix_socket")
    cls = SimpleEcho
    if options.example == 'chat':
        cls = SimpleChat

    if options.ssl == 1:
        server = SimpleSSLWebSocketServer(options.host,
                                          options.port,
                                          cls,
                                          options.cert,
                                          options.cert,
                                          version=options.ver)
    else:
        server = SimpleWebSocketServer(options.host, options.port, cls)

    # def close_sig_handler(signal, frame):
    #    server.close()
    #    sys.exit()

    # serverThread = threading.Thread(target=other_thread)
    # serverThread.daemon = True
    # serverThread.start()

    #signal.signal(signal.SIGINT, close_sig_handler)

    server.serveforever()
    from optparse import OptionParser

    usage = """Usage: %prog roiName obsID ccdColour sample line
                [target codes]"""

    descript = """Utility to 1. calculate ground coordinates for a given
    sample/line pair for a given obsID. 2. find all mosaic data cubes on the hirise
    server with the same target code (optional: 2nd additional target code)
    as the given obsID, that also have this point inside (negative results mean
    outside, positive might still lie in black part of map-projected mosaic).
    The roiName that is required will be used for the resulting csv data file.
    The created data file will contain calculated sample/line pairs for the
    found data cube mosaics"""

    parser = OptionParser(usage=usage, description=descript)
    parser.add_option("-t", "--target", dest="extraTargetCode",
                      help="optional 2nd targetcode to search")
    parser.add_option("-n", "--testing", action='store_true',
                      dest="testing", default=False,
                      help="test functionality without providing parameters")


    (options, args) = parser.parse_args()

     # create my parameter container
    params = roi.ROI_Data()

    params.extraTargetCode = options.extraTargetCode
    if options.testing:
        params.roiName = 'IncaCity'
        params.obsID = 'PSP_003092_0985'
        params.ccdColour = 'RED'
Example #30
0
def parse():
    parser.add_option('-i',
                      type="string",
                      help='The path of SQL Parser package ',
                      dest='input_path')
    base = core.Core()
    # base.banner()
    base.cmd_option()
    result = base.parse_log(core.burp_suite_log)
    for item in result:
        if base.gerequestinfo(item, "Host") == core.target_domain:
            headers = {}
            sp = item.split('\n\n', 1)
            if len(sp) > 1:
                head = sp[0]
                body = sp[1]
            else:
                head = sp[0]
                body = ""
            c1 = head.split('\n', head.count('\n'))
            method = c1[0].split(' ', 2)[0]
            path = c1[0].split(' ', 2)[1]
            for i in range(1, head.count('\n') + 1):
                slice1 = c1[i].split(': ', 1)
                if slice1[0] != "":
                    headers[slice1[0]] = slice1[1]

            session = requests.session()
            if method == 'GET':
                url = base.gerequestinfo(item, "Host") + path
                domain = url.split("?")[0]
                queries = urlparse(url).query.split("&")
                if not any(queries):
                    print('skip')
                else:
                    for i in range(len(queries)):
                        input = queries[i].split('=')[1]
                        output, payload = generator(input)
                        queries[i] = queries[i].split('=')[0] + '=' + payload
                    website = domain + "?" + ("&".join(
                        [param for param in queries]))
                    print(website)
                    session.get(url=website)
                    with open(input_path, 'r') as f:
                        sqltext = f.readline()
                    if SQLInjection.isInjected(sqltext):
                        with open('./output.txt', 'a') as f:
                            f.write(website + '\n')
            elif method == 'POST':
                print(body)
                queries = urlparse(body).query.split("&")
                if not any(queries):
                    print('skip')
                else:
                    for i in range(len(queries)):
                        input = queries[i].split('=')[1]
                        output = generator(input)
                        queries[i] = queries[i].split('=')[0] + '=' + output
                    website = domain + "?" + ("&".join(
                        [param for param in queries]))
                    print(website)
                    session.get(url=website)
                    with open(input_path, 'r') as f:
                        sqltext = f.readline()
                    if SQLInjection.isInjected(sqltext):
                        with open('./output.txt', 'a') as f:
                            f.write(website + '\n')
Example #31
0
import parser
import select
import time
import urllib.request, urllib.parse, urllib.error
from this import s
from gzip import GzipFile
from optparse import OptionParser



if __name__ == "__main__":
    
    usage = "usage: %prog [options] drk-file step "
    parser = OptionParser(usage)
    parser.add_option("-o", "--out", dest="out",
                     default="-",
                     help="input file (default %default)")
    (options, args) = parser.parse_args()    
    if len(args) < 2:
        parser.print_usage()
        sys.exit(1)
        
    
    fd = GzipFile(args[0], 'r')
   
    #aux buffer for new modified file
    output=""   
    #aux dict with keys src_dst combination and its corresponding line of the file as value.
    src_dst_dic={}
    #aux boolean dict with keys src_dst combination. 0=no response from DST yet, 1=response from DST for the last src_dst message.
    response={}
Example #32
0
def main():
    global mongod_executable, mongod_port, shell_executable, continue_on_failure, small_oplog, no_journal, no_preallocj, auth, keyFile, smoke_db_prefix, test_path
    parser = OptionParser(usage="usage: smoke.py [OPTIONS] ARGS*")
    parser.add_option(
        "--mode",
        dest="mode",
        default="suite",
        help='If "files", ARGS are filenames; if "suite", ARGS are sets of tests (%default)',
    )
    # Some of our tests hard-code pathnames e.g., to execute, so until
    # that changes we don't have the freedom to run from anyplace.
    # parser.add_option('--mongo-repo', dest='mongo_repo', default=None,
    parser.add_option(
        "--test-path",
        dest="test_path",
        default=None,
        help="Path to the test executables to run, " "currently only used for 'client' (%default)",
    )
    parser.add_option(
        "--mongod",
        dest="mongod_executable",
        default=os.path.join(mongo_repo, "mongod"),
        help="Path to mongod to run (%default)",
    )
    parser.add_option("--port", dest="mongod_port", default="27999", help="Port the mongod will bind to (%default)")
    parser.add_option(
        "--mongo",
        dest="shell_executable",
        default=os.path.join(mongo_repo, "mongo"),
        help="Path to mongo, for .js test files (%default)",
    )
    parser.add_option(
        "--continue-on-failure",
        dest="continue_on_failure",
        action="store_true",
        default=False,
        help="If supplied, continue testing even after a test fails",
    )
    parser.add_option(
        "--from-file", dest="File", help="Run tests/suites named in FILE, one test per line, '-' means stdin"
    )
    parser.add_option(
        "--smoke-db-prefix",
        dest="smoke_db_prefix",
        default=smoke_db_prefix,
        help="Prefix to use for the mongods' dbpaths ('%default')",
    )
    parser.add_option(
        "--small-oplog",
        dest="small_oplog",
        default=False,
        action="store_true",
        help="Run tests with master/slave replication & use a small oplog",
    )
    parser.add_option(
        "--small-oplog-rs",
        dest="small_oplog_rs",
        default=False,
        action="store_true",
        help="Run tests with replica set replication & use a small oplog",
    )
    parser.add_option(
        "--nojournal", dest="no_journal", default=False, action="store_true", help="Do not turn on journaling in tests"
    )
    parser.add_option(
        "--nopreallocj",
        dest="no_preallocj",
        default=False,
        action="store_true",
        help="Do not preallocate journal files in tests",
    )
    parser.add_option(
        "--auth",
        dest="auth",
        default=False,
        action="store_true",
        help="Run standalone mongods in tests with authentication enabled",
    )
    parser.add_option(
        "--authMechanism",
        dest="authMechanism",
        default="MONGO-CR",
        help="Use the given authentication mechanism, when --auth is used.",
    )
    parser.add_option(
        "--keyFile",
        dest="keyFile",
        default=None,
        help="Path to keyFile to use to run replSet and sharding tests with authentication enabled",
    )
    parser.add_option("--ignore", dest="ignore_files", default=None, help="Pattern of files to ignore in tests")
    parser.add_option(
        "--only-old-fails",
        dest="only_old_fails",
        default=False,
        action="store_true",
        help="Check the failfile and only run all tests that failed last time",
    )
    parser.add_option(
        "--reset-old-fails",
        dest="reset_old_fails",
        default=False,
        action="store_true",
        help="Clear the failfile. Do this if all tests pass",
    )
    parser.add_option(
        "--with-cleanbb",
        dest="with_cleanbb",
        default=False,
        action="store_true",
        help="Clear database files from previous smoke.py runs",
    )
    parser.add_option(
        "--dont-start-mongod",
        dest="start_mongod",
        default=True,
        action="store_false",
        help="Do not start mongod before commencing test running",
    )
    parser.add_option(
        "--use-ssl",
        dest="use_ssl",
        default=False,
        action="store_true",
        help="Run mongo shell and mongod instances with SSL encryption",
    )

    # Buildlogger invocation from command line
    parser.add_option(
        "--buildlogger-builder",
        dest="buildlogger_builder",
        default=None,
        action="store",
        help='Set the "builder name" for buildlogger',
    )
    parser.add_option(
        "--buildlogger-buildnum",
        dest="buildlogger_buildnum",
        default=None,
        action="store",
        help='Set the "build number" for buildlogger',
    )
    parser.add_option(
        "--buildlogger-credentials",
        dest="buildlogger_credentials",
        default=None,
        action="store",
        help="Path to Python file containing buildlogger credentials",
    )
    parser.add_option(
        "--buildlogger-phase",
        dest="buildlogger_phase",
        default=None,
        action="store",
        help='Set the "phase" for buildlogger (e.g. "core", "auth") for display in the webapp (optional)',
    )

    global tests
    (options, tests) = parser.parse_args()

    set_globals(options, tests)

    buildlogger_opts = (options.buildlogger_builder, options.buildlogger_buildnum, options.buildlogger_credentials)
    if all(buildlogger_opts):
        os.environ["MONGO_USE_BUILDLOGGER"] = "true"
        os.environ["MONGO_BUILDER_NAME"] = options.buildlogger_builder
        os.environ["MONGO_BUILD_NUMBER"] = options.buildlogger_buildnum
        os.environ["BUILDLOGGER_CREDENTIALS"] = options.buildlogger_credentials
        if options.buildlogger_phase:
            os.environ["MONGO_PHASE"] = options.buildlogger_phase
    elif any(buildlogger_opts):
        # some but not all of the required options were sete
        raise Exception("you must set all of --buildlogger-builder, --buildlogger-buildnum, --buildlogger-credentials")

    if options.File:
        if options.File == "-":
            tests = sys.stdin.readlines()
        else:
            f = open(options.File)
            tests = f.readlines()
    tests = [t.rstrip("\n") for t in tests]

    if options.only_old_fails:
        run_old_fails()
        return
    elif options.reset_old_fails:
        clear_failfile()
        return

    # If we're in suite mode, tests is a list of names of sets of tests.
    if options.mode == "suite":
        tests = expand_suites(tests)
    elif options.mode == "files":
        tests = [(os.path.abspath(test), start_mongod) for test in tests]

    if options.ignore_files != None:
        ignore_patt = re.compile(options.ignore_files)
        print "Ignoring files with pattern: ", ignore_patt

        def ignore_test(test):
            if ignore_patt.search(test[0]) != None:
                print "Ignoring test ", test[0]
                return False
            else:
                return True

        tests = filter(ignore_test, tests)

    if not tests:
        print "warning: no tests specified"
        return

    if options.with_cleanbb:
        dbroot = os.path.join(options.smoke_db_prefix, "data", "db")
        call([utils.find_python(), "buildscripts/cleanbb.py", "--nokill", dbroot])

    try:
        run_tests(tests)
    finally:
        add_to_failfile(fails, options)

        f = open("smoke-last.json", "wb")
        f.write(json.dumps({"results": all_test_results}))
        f.close()

        report()
Example #33
0
 def build_option_parser(self):
   parser = optparse.OptionParser()
   parser.add_option('--expression', action='append', default=[])
   parser.add_option('--program', action='append', default=[])
   parser.add_option('--file', action='append', default=[])
   parser.add_option('--filter', action='store_true', default=False)
   parser.add_option('--base64', action='store_true', default=False)
   parser.add_option('--disass', action='store_true', default=False)
   parser.add_option('--out', default=None)
   parser.add_option('--compile', action='callback', type='string', callback=parse_plankton_option)
   return parser
Example #34
0
def parseOptions():
  #note: newlines are not respected in the optparse description string :(, maybe someday will use
  #argparse, which does allow for raw formating (repects indents, newlines etc.)
  
  #setup command line parser
  '''This is out of date, needs to be updated to reflect new additions'''
  parser=op.OptionParser(usage="Usage: %prog [options] XMLFILE"
    ,version="%prog 1.0",description=r"Reads in the XMLFILE which specifies how the plot is to be "
    +"made and generates the plot of plots accordingly.")
    
  #these options apply globaly
  parser.add_option("-o","--outputFile",dest="outputFile",default="out"
    ,help="Specifies the OUTPUTFILE. [default: %default]"
    ,metavar="OUTPUTFILE", type="string")
  parser.add_option("-f","--format",dest="format",default="png", type="choice",
    help="Sets the FMT of the OUTPUTFILE, availble formats are 'png', 'pdf', 'ps', 'eps', and 'svg'."
    +"[default: %default]", metavar="FMT",choices=('png','pdf','ps','eps','svg'))
  parser.add_option("-s","--show",dest="show",action="store_true",default=False
    ,help="Display plot to x11 display rather than saving to a file.")
  parser.add_option("--dpi",dest="dpi",type="float",default=100
    ,help="Sets the dots per inch of the figure [default: %default]")
  parser.add_option("--space-axis-evenly",action="store_true",dest="spaceAxisEvenly"
    ,help="Will give the same amount of space per x-axis, instead of per plot. [not default]."
    ,default=False)
  
  #should likely be per plot, at the momement they are across all plots
  parser.add_option("--fig-width",dest="figWidth",type="float",default=15
    ,help="Set the width of the figure [default: %default]")
  parser.add_option("--fig-height",dest="figHeight",type="float",default=9
    ,help="Set the height of the figure [default: %default]")
  
  #parse command line options
  return parser.parse_args()
def start_server():
   parser = OptionParser(usage="usage: %prog [options]", version="%prog 1.0")
   parser.add_option("--host", default='', type='string', action="store", dest="host", help="hostname (localhost)")
   parser.add_option("--port", default=9001, type='int', action="store", dest="port", help="port (9001)")
   parser.add_option("--example", default='echo', type='string', action="store", dest="example", help="echo, chat")
   parser.add_option("--ssl", default=0, type='int', action="store", dest="ssl", help="ssl (1: on, 0: off (default))")
   parser.add_option("--cert", default='./cert.pem', type='string', action="store", dest="cert", help="cert (./cert.pem)")
   parser.add_option("--ver", default=ssl.PROTOCOL_TLSv1, type=int, action="store", dest="ver", help="ssl version")

   (options, args) = parser.parse_args()

   os.system("rm ./unix_socket")
   cls = SimpleEcho
   if options.example == 'chat':
      cls = SimpleChat

   if options.ssl == 1:
      server = SimpleSSLWebSocketServer(options.host, options.port, cls, options.cert, options.cert, version=options.ver)
   else:
      server = SimpleWebSocketServer(options.host, options.port, cls)

   # def close_sig_handler(signal, frame):
   #    server.close()
   #    sys.exit()

   # serverThread = threading.Thread(target=other_thread)
   # serverThread.daemon = True
   # serverThread.start()

   #signal.signal(signal.SIGINT, close_sig_handler)

   server.serveforever()
Example #36
0
def Main():
    parser = optparse.OptionParser()
    parser.add_option("-p", "--publishToRepo",
        help='Publish binaries to specified dist repo.',
        default=None)
    (options, args) = parser.parse_args()

    userhome = os.path.expanduser("~")
    platformid = platform.system()
    env = os.environ.copy()
    if platformid == "Linux":
        env["ORACLE_OCI_HOME"] = "%s/Downloads/instantclient_11_2/sdk" % userhome
        env["ORACLE_OCCI_LIB_HOME"] = "%s/Downloads/instantclient_11_2" % userhome
        buildCommand = ['make', '-j', '8', 'BUILDTYPE=ReleaseIA32']
        extensionlibrary = "out/ReleaseIA32/lib.target/liboracledart_extension.so"
    elif platformid == "Darwin":
        ORACLE_OCCI_LIB_HOME = "%s/Downloads/instantclient_11_2-2" % userhome
        subprocess.call(
            ["ln",
             "%s/libocci.dylib.11.1" % ORACLE_OCCI_LIB_HOME,
             "%s/libocci.dylib" % ORACLE_OCCI_LIB_HOME])
        subprocess.call(
            ["ln",
             "%s/ORACLE_OCCI_LIB_HOME/libclntsh.dylib.11.1" % ORACLE_OCCI_LIB_HOME,
             "%s/libclntsh.dylib" % ORACLE_OCCI_LIB_HOME])
        env["ORACLE_OCI_HOME"] = "%s/Downloads/instantclient_11_2/sdk" % userhome
        env["ORACLE_OCCI_LIB_HOME"] = ORACLE_OCCI_LIB_HOME
        buildCommand = ['xcodebuild',
                '-project', 'oracledart.xcodeproj',
                '-configuration', 'ReleaseIA32',
                'SYMROOT=%s/../dart/xcodebuild' % os.getcwd()]
        extensionlibrary = (
            "../dart/xcodebuild/ReleaseIA32/liboracledart_extension.dylib")
    elif platformid == "Windows" or platformid == "Microsoft":
        if not "JAVA_HOME" in env:
            print "JAVA_HOME is not set up"
            return 3
        os.system("mklink /J third_party ..\\dart\\third_party")
        env["ORACLE_OCI_HOME"] = (
            "%s\\downloads\\instantclient-sdk-nt-12.1.0.1.0\\instantclient_12_1\\sdk" %
            userhome)
        buildCommand = ['devenv.com',
                'oracledart.sln',
                '/build',
                'ReleaseIA32']
        extensionlibrary = (
            "build\\ReleaseIA32\\oracledart_extension.dll")
    else:
        print "Unsupported platform"
        return 1

    print " ".join(buildCommand)
    process = subprocess.Popen(buildCommand, stdin=None, env=env)
    process.wait()
    print "Completed with %d" % (process.returncode)
    if process.returncode == 0:
        if platformid == "Linux" or platformid == "Darwin":
            subprocess.call("cp %s lib" % (extensionlibrary), shell=True)
        else:
            subprocess.call(["copy", extensionlibrary, "lib"], shell=True)
        if (options.publishToRepo != None):
            subprocess.call(
                ["python", "./tools/deploy.py", "-p", options.publishToRepo, "-f", extensionlibrary])
    return process.returncode
Example #37
0
        if pn is None or not os.path.exists(pn):
            return 0
        return os.stat(pn).st_size

    for fs in fsop.get_all_fs():
        one = _get_merged_file(fs)
        fss = _get_fss_file(fs)

        print "%-10s %10s B %10s B" % (fs, _get_size(one), _get_size(fss))


if __name__ == '__main__':
    utils.install_pdb()

    parser = optparse.OptionParser()
    parser.add_option("--linux", help="Linux kernel", default=LINUX)
    parser.add_option("--clang", help="Clang path", default=CLANG)
    parser.add_option("--outdir", help="Clang output dir", default="/tmp")
    (opts, args) = parser.parse_args()

    def __print_usage(note):
        print(note)
        for (cmd, func) in get_all_cmds():
            print("> %-20s: %s" % (cmd, func.__doc__))
        exit(0)

    if len(args) == 0:
        __print_usage("Need to specify a command")

    cmd = args[0]
    if get_cmd(cmd) is None:
Example #38
0
def parseOptions():
  #note: newlines are not respected in the optparse description string :(, maybe someday will use
  #argparse, which does allow for raw formating (repects indents, newlines etc.)
  
  #setup command line parser
  '''This is out of date, needs to be updated to reflect new additions'''
  parser=op.OptionParser(usage="Usage: %prog [options] XMLFILE"
    ,version="%prog 1.0",description=r"Reads in the XMLFILE which specifies how the plot is to be "
    +"made and generates the plot of plots accordingly.")
    
  #these options apply globaly
  parser.add_option("-s","--show",dest="show",action="store_true",default=False
    ,help="Display plot to x11 display rather than saving to a file.")
  parser.add_option("-f","--file",dest="file",action="store_true",default=False
    ,help="Instead of plotting the data will be written to an ascii file.")
  parser.add_option("--dpi",dest="dpi",type="float",default=100
    ,help="Sets the dots per inch of the figure [default: %default]")
  parser.add_option("--space-axis-evenly",action="store_true",dest="spaceAxisEvenly"
    ,help="Will give the same amount of space per x-axis, instead of per plot. [not default]."
    ,default=False)
  
  #should likely be per plot, at the momement they are across all plots
  parser.add_option("--zone-index-from-center",dest="zoneIndexFromCenter",
    help="Specifies the radial zone at which to plot the desired column should starts with the "
    "center zone equal to zero and the zone number increasing towards the surface"
    ,action="store_true",default=False)
  parser.add_option("--fig-width",dest="figWidth",type="float",default=15
    ,help="Set the width of the figure [default: %default]")
  parser.add_option("--fig-height",dest="figHeight",type="float",default=9
    ,help="Set the height of the figure [default: %default]")
  
  make_profiles.addParserOptions(parser)
  
  #parse command line options
  return parser.parse_args()
Example #39
0
def runBatch():
    parser = OptionParser()
    parser.set_usage(parser.get_usage().rstrip() + " {create | start | stop | clean | drop}")
    parser.add_option("-t", "--tables", dest="tables", type="string", default="test: Blog"
        , help = "format: \"dbname1: table1 table2;dbname2: table3;\"")
    parser.add_option("-m", "--home", dest="mysqlhome", type="string", default="/usr"
        , help = "mysql home directory")
    parser.add_option("-H", "--host", dest="mysqlhost", type="string", default="127.0.0.1"
        , help = "mysql server address")
    parser.add_option("-P", "--port", dest="mysqlport", type="int", default = 3306
        , help = "mysql server port")
    parser.add_option("-u", "--user", dest="mysqluser", type="string", default = "root"
        , help = "mysql server user name")
    parser.add_option("-p", "--password", dest="mysqlpassword", type="string", default=""
        , help = "mysql server password")
    parser.add_option("-e", "--engine", dest="engine", type="string", default="innodb"
    		, help = "mysql storage engine")
    parser.add_option("-i", "--iteration", dest="iteration", type=int
    		,	help = "the iteration times of query information_schemation database")
    parser.add_option("-o", "--output", dest="output", type="string", default="./"
    		, help = "output directory for result")
    
    (options, args) = parser.parse_args()
    
    tables = []
    if options.tables != None:
        options.tables.strip(";")
        for dbtabs in options.tables.split(";"):
            str = dbtabs.split(":")
            print str
            tables.append((str[0], str[1].split()))
    if len(args) <= 0:
        parser.print_usage()
        return

    if args[0] == "create":
        StatisticianRunner.createTest(options.output, MysqlConfig(options.mysqlhome, options.mysqlhost
            , options.mysqlport, options.mysqluser, options.mysqlpassword), options.engine, tables)
    elif args[0] == "start":
        if options.iteration == None:
    		parser.print_usage()
    		return
        StatisticianRunner.start(options.output, options.iteration)
    elif args[0] == "stop":
        StatisticianRunner.stop(options.output)
    elif args[0] == "clean":
        StatisticianRunner.clean(options.output)
    elif args[0] == "drop":
        StatisticianRunner.drop(options.output)
    else:
        parser.print_usage()
        return
Example #40
0
def _parse_args():
	'''Parse the command-line arguments.'''
	parser = OptionParser(usage='%prog [Options] <device>', version='%prog 0.5')
	parser.add_option('-p', '--purge',
		dest='purge',
		help='purge the tracklog memory on the device',
		action='store_true',
		default=False)
	parser.add_option('-d', '--download',
		dest='download',
		help='download tracklogs from device',
		action='store_true',
		default=False)
	parser.add_option('-t', '--target-dir',
		dest='target_dir',
		help='target directory for downloaded tracklogs [default: %default]',
		default='%s/mainnav-tracklogs/' % os.environ.get('HOME', tempfile.gettempdir()))
	parser.add_option('-u', '--utc',
		dest='utc_offset',
		help='generate GPX time entry in UTC by declaring the offset (your timezone, e.g. -5 or +9.5)',
		type='float',
		default=False)
	parser.add_option('-r', '--raw',
		dest='raw',
		help='store the raw binary data in the target directory (must be combined with the download option)',
		action='store_true',
		default=False)
	parser.add_option('-m', '--memory',
		dest='memory',
		help='show the amount of memory in use',
		action='store_true',
		default=False)
	parser.add_option('-v', '--verbose',
		dest='verbose',
		help='be verbose',
		action='store_true',
		default=False)

	(options, args) = parser.parse_args()

	try:
		options.device = args[0]
	except IndexError:
		options.device = ''
	if not options.device:
		parser.error('please specify device path, for example \'/dev/ttyUSB0\'')
	if options.download and options.purge:
		parser.error('options -d and -p are mutually exclusive')
	if options.download and options.memory:
		parser.error('options -d and -m are mutually exclusive')
	if options.memory and options.purge:
		parser.error('options -m and -p are mutually exclusive')

	return options
Example #41
0
import parser
import os
import os.path
import glob

from tempfile import mkstemp
from subprocess import Popen

from optparse import OptionParser

parser = OptionParser(usage="usage: %prog [options] <SQL scripts path>", add_help_option=False)

parser.add_option("--help", action="store_true", dest="help", default=False)

parser.add_option("--mysql", dest="mysql", default="mysql", help="Default mysql binary")

parser.add_option("--browser-db", dest="browser_db", default=None, metavar="NAME", help="Browser database name")

parser.add_option("--biomart-db", dest="biomart_db", default=None, metavar="NAME", help="Biomart database name")

parser.add_option("--start", dest="start_file", default=None, metavar="NAME", help="SQL file to start with. Optional")

parser.add_option("-h", "--host", dest="db_host", default=None, metavar="HOST", help="host")
parser.add_option("-P", "--port", dest="db_port", default=None, metavar="PORT", help="port")
parser.add_option("-u", "--user", dest="db_user", default=None, metavar="NAME", help="user name")
parser.add_option("-p", "--passwd", dest="db_passwd", default=None, metavar="PASSWD", help="password")

(options, args) = parser.parse_args()

if options.help:
    parser.print_help()
Example #42
0
import parser
import select
import time
import urllib
from this import s
from gzip import GzipFile
from optparse import OptionParser



if __name__ == "__main__":
    
    usage = "usage: %prog [options] drk-file step "
    parser = OptionParser(usage)
    parser.add_option("-o", "--out", dest="out",
                     default="-",
                     help="input file (default %default)")
    (options, args) = parser.parse_args()    
    if len(args) < 2:
        parser.print_usage()
        sys.exit(1)
        
    
    fd = GzipFile(args[0], 'r')
   
    #aux buffer for new modified file
    output=""   
    #aux dict with keys src_dst combination and its corresponding line of the file as value.
    src_dst_dic={}
    #aux boolean dict with keys src_dst combination. 0=no response from DST yet, 1=response from DST for the last src_dst message.
    response={}
Example #43
0
def main():
    global mongod_executable, mongod_port, shell_executable, continue_on_failure, small_oplog, no_journal, set_parameters, no_preallocj, auth, keyFile, smoke_db_prefix, test_path
    parser = OptionParser(usage="usage: smoke.py [OPTIONS] ARGS*")
    parser.add_option('--mode', dest='mode', default='suite',
                      help='If "files", ARGS are filenames; if "suite", ARGS are sets of tests (%default)')
    # Some of our tests hard-code pathnames e.g., to execute, so until
    # that changes we don't have the freedom to run from anyplace.
    # parser.add_option('--mongo-repo', dest='mongo_repo', default=None,
    parser.add_option('--test-path', dest='test_path', default=None,
                      help="Path to the test executables to run, "
                      "currently only used for 'client' (%default)")
    parser.add_option('--mongod', dest='mongod_executable', default=os.path.join(mongo_repo, 'mongod'),
                      help='Path to mongod to run (%default)')
    parser.add_option('--port', dest='mongod_port', default="27999",
                      help='Port the mongod will bind to (%default)')
    parser.add_option('--mongo', dest='shell_executable', default=os.path.join(mongo_repo, 'mongo'),
                      help='Path to mongo, for .js test files (%default)')
    parser.add_option('--continue-on-failure', dest='continue_on_failure',
                      action="store_true", default=False,
                      help='If supplied, continue testing even after a test fails')
    parser.add_option('--from-file', dest='File',
                      help="Run tests/suites named in FILE, one test per line, '-' means stdin")
    parser.add_option('--smoke-db-prefix', dest='smoke_db_prefix', default=smoke_db_prefix,
                      help="Prefix to use for the mongods' dbpaths ('%default')")
    parser.add_option('--small-oplog', dest='small_oplog', default=False,
                      action="store_true",
                      help='Run tests with master/slave replication & use a small oplog')
    parser.add_option('--small-oplog-rs', dest='small_oplog_rs', default=False,
                      action="store_true",
                      help='Run tests with replica set replication & use a small oplog')
    parser.add_option('--nojournal', dest='no_journal', default=False,
                      action="store_true",
                      help='Do not turn on journaling in tests')
    parser.add_option('--nopreallocj', dest='no_preallocj', default=False,
                      action="store_true",
                      help='Do not preallocate journal files in tests')
    parser.add_option('--auth', dest='auth', default=False,
                      action="store_true",
                      help='Run standalone mongods in tests with authentication enabled')
    parser.add_option('--authMechanism', dest='authMechanism', default='MONGODB-CR',
                      help='Use the given authentication mechanism, when --auth is used.')
    parser.add_option('--keyFile', dest='keyFile', default=None,
                      help='Path to keyFile to use to run replSet and sharding tests with authentication enabled')
    parser.add_option('--ignore', dest='ignore_files', default=None,
                      help='Pattern of files to ignore in tests')
    parser.add_option('--only-old-fails', dest='only_old_fails', default=False,
                      action="store_true",
                      help='Check the failfile and only run all tests that failed last time')
    parser.add_option('--reset-old-fails', dest='reset_old_fails', default=False,
                      action="store_true",
                      help='Clear the failfile. Do this if all tests pass')
    parser.add_option('--with-cleanbb', dest='with_cleanbb', default=False,
                      action="store_true",
                      help='Clear database files from previous smoke.py runs')
    parser.add_option('--dont-start-mongod', dest='start_mongod', default=True,
                      action='store_false',
                      help='Do not start mongod before commencing test running')
    parser.add_option('--use-ssl', dest='use_ssl', default=False,
                      action='store_true',
                      help='Run mongo shell and mongod instances with SSL encryption')
    parser.add_option('--set-parameters', dest='set_parameters', default="",
                      help='Adds --setParameter for each passed in items in the csv list - ex. "param1=1,param2=foo" ')
    # Buildlogger invocation from command line
    parser.add_option('--buildlogger-builder', dest='buildlogger_builder', default=None,
                      action="store", help='Set the "builder name" for buildlogger')
    parser.add_option('--buildlogger-buildnum', dest='buildlogger_buildnum', default=None,
                      action="store", help='Set the "build number" for buildlogger')
    parser.add_option('--buildlogger-credentials', dest='buildlogger_credentials', default=None,
                      action="store", help='Path to Python file containing buildlogger credentials')
    parser.add_option('--buildlogger-phase', dest='buildlogger_phase', default=None,
                      action="store", help='Set the "phase" for buildlogger (e.g. "core", "auth") for display in the webapp (optional)')
    parser.add_option('--report-file', dest='report_file', default=None,
                      action='store',
                      help='Path to generate detailed json report containing all test details')


    global tests
    (options, tests) = parser.parse_args()

    set_globals(options, tests)

    buildlogger_opts = (options.buildlogger_builder, options.buildlogger_buildnum, options.buildlogger_credentials)
    if all(buildlogger_opts):
        os.environ['MONGO_USE_BUILDLOGGER'] = 'true'
        os.environ['MONGO_BUILDER_NAME'] = options.buildlogger_builder
        os.environ['MONGO_BUILD_NUMBER'] = options.buildlogger_buildnum
        os.environ['BUILDLOGGER_CREDENTIALS'] = options.buildlogger_credentials
        if options.buildlogger_phase:
            os.environ['MONGO_PHASE'] = options.buildlogger_phase
    elif any(buildlogger_opts):
        # some but not all of the required options were sete
        raise Exception("you must set all of --buildlogger-builder, --buildlogger-buildnum, --buildlogger-credentials")

    if options.File:
        if options.File == '-':
            tests = sys.stdin.readlines()
        else:
            f = open(options.File)
            tests = f.readlines()
    tests = [t.rstrip('\n') for t in tests]

    if options.only_old_fails:
        run_old_fails()
        return
    elif options.reset_old_fails:
        clear_failfile()
        return

    # If we're in suite mode, tests is a list of names of sets of tests.
    if options.mode == 'suite':
        tests = expand_suites(tests)
    elif options.mode == 'files':
        tests = [(os.path.abspath(test), start_mongod) for test in tests]

    if options.ignore_files != None :
        ignore_patt = re.compile( options.ignore_files )
        print "Ignoring files with pattern: ", ignore_patt

        def ignore_test( test ):
            if ignore_patt.search( test[0] ) != None:
                print "Ignoring test ", test[0]
                return False
            else:
                return True

        tests = filter( ignore_test, tests )

    if not tests:
        print "warning: no tests specified"
        return

    if options.with_cleanbb:
        dbroot = os.path.join(options.smoke_db_prefix, 'data', 'db')
        call([utils.find_python(), "buildscripts/cleanbb.py", "--nokill", dbroot])

    test_report["start"] = time.time()
    try:
        run_tests(tests)
    finally:
        add_to_failfile(fails, options)

        test_report["end"] = time.time()
        test_report["elapsed"] = test_report["end"] - test_report["start"]
        test_report["failures"] = len(losers.keys())
        if report_file:
            f = open( report_file, "wb" )
            f.write( json.dumps( test_report ) )
            f.close()

        report()
Example #44
0
    def __init__(self):
        QtGui.QDialog.__init__(self)
        # Set up the user interface from Designer.
        self.ui = Ui_WaterForm()
        self.ui.setupUi(self)"""
)

compliestring = Template("pyuic4 -o ui_$py.py $ui")

if __name__ == "__main__":
    """
        Helper to create the form folder structure with the correct layer and files
    """

    parser = OptionParser()
    parser.add_option("-f", "--folder", dest="foldername", help="Overwrite folder name for form folder", metavar="NAME")

    (options, args) = parser.parse_args()

    if not len(args) == 3:
        parser.error("incorrect number of arguments")

    filename = args[0]
    layer = args[1]
    name = args[2]
    if not filename[-3:] == ".ui":
        parser.error("incorrect number of arguments")

    newfilename = filename.replace(" ", "")
    print filename
    foldername = "form%s" % (options.foldername or newfilename[:-3])
Example #45
0
def main():
    global mongod_executable, mongod_port, shell_executable, continue_on_failure, small_oplog, no_journal, set_parameters, no_preallocj, auth, keyFile, smoke_db_prefix, test_path
    parser = OptionParser(usage="usage: smoke.py [OPTIONS] ARGS*")
    parser.add_option(
        '--mode',
        dest='mode',
        default='suite',
        help=
        'If "files", ARGS are filenames; if "suite", ARGS are sets of tests (%default)'
    )
    # Some of our tests hard-code pathnames e.g., to execute, so until
    # that changes we don't have the freedom to run from anyplace.
    # parser.add_option('--mongo-repo', dest='mongo_repo', default=None,
    parser.add_option('--test-path',
                      dest='test_path',
                      default=None,
                      help="Path to the test executables to run, "
                      "currently only used for 'client' (%default)")
    parser.add_option('--mongod',
                      dest='mongod_executable',
                      default=os.path.join(mongo_repo, 'mongod'),
                      help='Path to mongod to run (%default)')
    parser.add_option('--port',
                      dest='mongod_port',
                      default="27999",
                      help='Port the mongod will bind to (%default)')
    parser.add_option('--mongo',
                      dest='shell_executable',
                      default=os.path.join(mongo_repo, 'mongo'),
                      help='Path to mongo, for .js test files (%default)')
    parser.add_option(
        '--continue-on-failure',
        dest='continue_on_failure',
        action="store_true",
        default=False,
        help='If supplied, continue testing even after a test fails')
    parser.add_option(
        '--from-file',
        dest='File',
        help=
        "Run tests/suites named in FILE, one test per line, '-' means stdin")
    parser.add_option(
        '--smoke-db-prefix',
        dest='smoke_db_prefix',
        default=smoke_db_prefix,
        help="Prefix to use for the mongods' dbpaths ('%default')")
    parser.add_option(
        '--small-oplog',
        dest='small_oplog',
        default=False,
        action="store_true",
        help='Run tests with master/slave replication & use a small oplog')
    parser.add_option(
        '--small-oplog-rs',
        dest='small_oplog_rs',
        default=False,
        action="store_true",
        help='Run tests with replica set replication & use a small oplog')
    parser.add_option('--nojournal',
                      dest='no_journal',
                      default=False,
                      action="store_true",
                      help='Do not turn on journaling in tests')
    parser.add_option('--nopreallocj',
                      dest='no_preallocj',
                      default=False,
                      action="store_true",
                      help='Do not preallocate journal files in tests')
    parser.add_option(
        '--auth',
        dest='auth',
        default=False,
        action="store_true",
        help='Run standalone mongods in tests with authentication enabled')
    parser.add_option(
        '--authMechanism',
        dest='authMechanism',
        default='MONGODB-CR',
        help='Use the given authentication mechanism, when --auth is used.')
    parser.add_option(
        '--keyFile',
        dest='keyFile',
        default=None,
        help=
        'Path to keyFile to use to run replSet and sharding tests with authentication enabled'
    )
    parser.add_option('--ignore',
                      dest='ignore_files',
                      default=None,
                      help='Pattern of files to ignore in tests')
    parser.add_option(
        '--only-old-fails',
        dest='only_old_fails',
        default=False,
        action="store_true",
        help='Check the failfile and only run all tests that failed last time')
    parser.add_option('--reset-old-fails',
                      dest='reset_old_fails',
                      default=False,
                      action="store_true",
                      help='Clear the failfile. Do this if all tests pass')
    parser.add_option('--with-cleanbb',
                      dest='with_cleanbb',
                      default=False,
                      action="store_true",
                      help='Clear database files from previous smoke.py runs')
    parser.add_option(
        '--dont-start-mongod',
        dest='start_mongod',
        default=True,
        action='store_false',
        help='Do not start mongod before commencing test running')
    parser.add_option(
        '--use-ssl',
        dest='use_ssl',
        default=False,
        action='store_true',
        help='Run mongo shell and mongod instances with SSL encryption')
    parser.add_option(
        '--set-parameters',
        dest='set_parameters',
        default="",
        help=
        'Adds --setParameter for each passed in items in the csv list - ex. "param1=1,param2=foo" '
    )
    # Buildlogger invocation from command line
    parser.add_option('--buildlogger-builder',
                      dest='buildlogger_builder',
                      default=None,
                      action="store",
                      help='Set the "builder name" for buildlogger')
    parser.add_option('--buildlogger-buildnum',
                      dest='buildlogger_buildnum',
                      default=None,
                      action="store",
                      help='Set the "build number" for buildlogger')
    parser.add_option(
        '--buildlogger-credentials',
        dest='buildlogger_credentials',
        default=None,
        action="store",
        help='Path to Python file containing buildlogger credentials')
    parser.add_option(
        '--buildlogger-phase',
        dest='buildlogger_phase',
        default=None,
        action="store",
        help=
        'Set the "phase" for buildlogger (e.g. "core", "auth") for display in the webapp (optional)'
    )

    global tests
    (options, tests) = parser.parse_args()

    set_globals(options, tests)

    buildlogger_opts = (options.buildlogger_builder,
                        options.buildlogger_buildnum,
                        options.buildlogger_credentials)
    if all(buildlogger_opts):
        os.environ['MONGO_USE_BUILDLOGGER'] = 'true'
        os.environ['MONGO_BUILDER_NAME'] = options.buildlogger_builder
        os.environ['MONGO_BUILD_NUMBER'] = options.buildlogger_buildnum
        os.environ['BUILDLOGGER_CREDENTIALS'] = options.buildlogger_credentials
        if options.buildlogger_phase:
            os.environ['MONGO_PHASE'] = options.buildlogger_phase
    elif any(buildlogger_opts):
        # some but not all of the required options were sete
        raise Exception(
            "you must set all of --buildlogger-builder, --buildlogger-buildnum, --buildlogger-credentials"
        )

    if options.File:
        if options.File == '-':
            tests = sys.stdin.readlines()
        else:
            f = open(options.File)
            tests = f.readlines()
    tests = [t.rstrip('\n') for t in tests]

    if options.only_old_fails:
        run_old_fails()
        return
    elif options.reset_old_fails:
        clear_failfile()
        return

    # If we're in suite mode, tests is a list of names of sets of tests.
    if options.mode == 'suite':
        tests = expand_suites(tests)
    elif options.mode == 'files':
        tests = [(os.path.abspath(test), start_mongod) for test in tests]

    if options.ignore_files != None:
        ignore_patt = re.compile(options.ignore_files)
        print "Ignoring files with pattern: ", ignore_patt

        def ignore_test(test):
            if ignore_patt.search(test[0]) != None:
                print "Ignoring test ", test[0]
                return False
            else:
                return True

        tests = filter(ignore_test, tests)

    if not tests:
        print "warning: no tests specified"
        return

    if options.with_cleanbb:
        dbroot = os.path.join(options.smoke_db_prefix, 'data', 'db')
        call([
            utils.find_python(), "buildscripts/cleanbb.py", "--nokill", dbroot
        ])

    try:
        run_tests(tests)
    finally:
        add_to_failfile(fails, options)

        f = open("smoke-last.json", "wb")
        f.write(json.dumps({"results": all_test_results}))
        f.close()

        report()
Example #46
0
def main():
    global mongod_executable, mongod_port, shell_executable, continue_on_failure, small_oplog, no_journal, no_preallocj, auth, keyFile, smoke_db_prefix, smoke_server_opts, test_path
    parser = OptionParser(usage="usage: smoke.py [OPTIONS] ARGS*")
    parser.add_option('--mode', dest='mode', default='suite',
                      help='If "files", ARGS are filenames; if "suite", ARGS are sets of tests (%default)')
    # Some of our tests hard-code pathnames e.g., to execute, so until
    # that changes we don't have the freedom to run from anyplace.
    # parser.add_option('--mongo-repo', dest='mongo_repo', default=None,
    parser.add_option('--test-path', dest='test_path', default=None,
                      help="Path to the test executables to run, "
                      "currently only used for 'client' (%default)")
    parser.add_option('--mongod', dest='mongod_executable', default=os.path.join(mongo_repo, 'mongod'),
                      help='Path to mongod to run (%default)')
    parser.add_option('--port', dest='mongod_port', default="27999",
                      help='Port the mongod will bind to (%default)')
    parser.add_option('--mongo', dest='shell_executable', default=os.path.join(mongo_repo, 'mongo'),
                      help='Path to mongo, for .js test files (%default)')
    parser.add_option('--continue-on-failure', dest='continue_on_failure',
                      action="store_true", default=False,
                      help='If supplied, continue testing even after a test fails')
    parser.add_option('--from-file', dest='File',
                      help="Run tests/suites named in FILE, one test per line, '-' means stdin")
    parser.add_option('--smoke-db-prefix', dest='smoke_db_prefix', default=smoke_db_prefix,
                      help="Prefix to use for the mongods' dbpaths ('%default')")
    parser.add_option('--smoke-server-opts', dest='smoke_server_opts', default=smoke_server_opts,
                      help="Additional options for the mongod server ('%default')")
    parser.add_option('--small-oplog', dest='small_oplog', default=False,
                      action="store_true",
                      help='Run tests with master/slave replication & use a small oplog')
    parser.add_option('--small-oplog-rs', dest='small_oplog_rs', default=False,
                      action="store_true",
                      help='Run tests with replica set replication & use a small oplog')
    parser.add_option('--nojournal', dest='no_journal', default=False,
                      action="store_true",
                      help='Do not turn on journaling in tests')
    parser.add_option('--nopreallocj', dest='no_preallocj', default=False,
                      action="store_true",
                      help='Do not preallocate journal files in tests')
    parser.add_option('--auth', dest='auth', default=False,
                      action="store_true",
                      help='Run standalone mongods in tests with authentication enabled')
    parser.add_option('--keyFile', dest='keyFile', default=None,
                      help='Path to keyFile to use to run replSet and sharding tests with authentication enabled')
    parser.add_option('--ignore', dest='ignore_files', default=None,
                      help='Pattern of files to ignore in tests')
    parser.add_option('--only-old-fails', dest='only_old_fails', default=False,
                      action="store_true",
                      help='Check the failfile and only run all tests that failed last time')
    parser.add_option('--reset-old-fails', dest='reset_old_fails', default=False,
                      action="store_true",
                      help='Clear the failfile. Do this if all tests pass')
    parser.add_option('--with-cleanbb', dest='with_cleanbb', default=False,
                      action="store_true",
                      help='Clear database files from previous smoke.py runs')
    parser.add_option('--server-log', dest='server_log_file', default=server_log_file,
                      help="Log file for the mongod server ('%default')")
    parser.add_option('--tests-log', dest='tests_log_file', default='',
                      help="Log file for the tests ('%default')")
    parser.add_option('--quiet', dest='quiet', default=False,
                      action="store_true",
                      help='Generate a quieter report (use with --tests-log)')
    parser.add_option('--shuffle', dest='shuffle', default=False,
                      action="store_true",
                      help='Shuffle tests instead of running them in alphabetical order')

    # Buildlogger invocation from command line
    parser.add_option('--buildlogger-builder', dest='buildlogger_builder', default=None,
                      action="store", help='Set the "builder name" for buildlogger')
    parser.add_option('--buildlogger-buildnum', dest='buildlogger_buildnum', default=None,
                      action="store", help='Set the "build number" for buildlogger')
    parser.add_option('--buildlogger-credentials', dest='buildlogger_credentials', default=None,
                      action="store", help='Path to Python file containing buildlogger credentials')
    parser.add_option('--buildlogger-phase', dest='buildlogger_phase', default=None,
                      action="store", help='Set the "phase" for buildlogger (e.g. "core", "auth") for display in the webapp (optional)')

    global tests
    (options, tests) = parser.parse_args()

    set_globals(options, tests)

    buildlogger_opts = (options.buildlogger_builder, options.buildlogger_buildnum, options.buildlogger_credentials)
    if all(buildlogger_opts):
        os.environ['MONGO_USE_BUILDLOGGER'] = 'true'
        os.environ['MONGO_BUILDER_NAME'] = options.buildlogger_builder
        os.environ['MONGO_BUILD_NUMBER'] = options.buildlogger_buildnum
        os.environ['BUILDLOGGER_CREDENTIALS'] = options.buildlogger_credentials
        if options.buildlogger_phase:
            os.environ['MONGO_PHASE'] = options.buildlogger_phase
    elif any(buildlogger_opts):
        # some but not all of the required options were sete
        raise Exception("you must set all of --buildlogger-builder, --buildlogger-buildnum, --buildlogger-credentials")

    if options.File:
        if options.File == '-':
            tests = sys.stdin.readlines()
        else:
            f = open(options.File)
            tests = f.readlines()
    tests = [t.rstrip('\n') for t in tests]

    if options.only_old_fails:
        run_old_fails()
        return
    elif options.reset_old_fails:
        clear_failfile()
        return

    # If we're in suite mode, tests is a list of names of sets of tests.
    if options.mode == 'suite':
        tests = expand_suites(tests)
    elif options.mode == 'files':
        tests = [(os.path.abspath(test), True) for test in tests]

    if options.ignore_files != None :
        ignore_patt = re.compile( options.ignore_files )
        tests = filter( lambda x : ignore_patt.search( x[0] ) == None, tests )

    if not tests:
        print "warning: no tests specified"
        return

    if options.with_cleanbb:
        dbroot = os.path.join(options.smoke_db_prefix, 'data', 'db')
        if options.quiet:
            f = open(server_log_file, "a")
            try:
                call([utils.find_python(), "buildscripts/cleanbb.py", "--nokill", dbroot], stdout=f)
            finally:
                f.close()
        else:
            call([utils.find_python(), "buildscripts/cleanbb.py", "--nokill", dbroot])

    if options.shuffle:
        import random
        random.shuffle(tests)

    try:
        run_tests(tests)
    finally:
        add_to_failfile(fails, options)
        report()