Пример #1
0
def getOptions():
    if sys.version_info >= (2, 7):
        from argparse import ArgumentParser

        parser = ArgumentParser(description="Turn SBML model into URDME 1.2 model files.")
        parser.add_argument(
            "-f", "--file", action="store", help="Input file name (SBML format)", default="model.xml", dest="input"
        )
        parser.add_argument(
            "-o", "--output", action="store", help="Output destination (directory)", default=".", dest="output"
        )
        return parser.parse_args()
    else:
        from optparse import OptionParser

        parser = OptionParser()
        parser.add_option(
            "-f", "--file", help="Input file name (SBML format)", type="string", default="model.xml", dest="input"
        )
        parser.add_option(
            "-o", "--output", help="Output destination (directory)", type="string", default=".", dest="output"
        )
        (opts, args) = parser.parse_args()
        return opts
Пример #2
0
Файл: cli.py Проект: arcege/pwdb

console = None

if __name__ == "__main__":
    if ArgumentParser:
        # console.write('\n')
        parser = ArgumentParser()
        parser.add_argument("-f", "--file", dest="filename", help="different database file", metavar="dbfile")
        args = parser.parse_args()
        if args.filename:
            DB_Filename = args.filename
    elif OptionParser:
        # console.write('\n')
        parser = OptionParser()
        parser.add_option("-f", "--file", dest="filename", help="different database file", metavar="dbfile")
        (opts, args) = parser.parse_args()
        if opts.filename:
            DB_Filename = opts.filename
    else:
        # console.write('\n')
        try:
            opts, args = getopt.getopt(sys.argv[1:], "f:h", ["file=", "help"])
        except getopt.error:
            et, ev, es = sys.exc_info()
            raise SystemExit(ev)
        for opt, val in opts:
            if opt == "--":
                break
            elif opt in ("-h", "--help"):
                console.write("% [opts]\n" % sys.argv[0])
Пример #3
0
# Username and password

optparser.add_option("-u", "--user", dest="user", action="store", type="string", help="user to connect as")

optparser.add_option(
    "-p", "--password", dest="password", action="store", type="string", help="password to connect user as"
)

# Change the default namespace used

optparser.add_option(
    "-n",
    "--namespace",
    dest="namespace",
    action="store",
    type="string",
    default="root/cimv2",
    help="default namespace to use",
)

# Don't use SSL for remote connections

optparser.add_option("--no-ssl", dest="no_ssl", action="store_true", help="don't use SSL")

# Specify non-standard port

optparser.add_option("--port", dest="port", action="store", type="int", help="port to connect as", default=None)

# Check usage
Пример #4
0
    parser.add_option("-v", "--verbose", dest="verbose_level", 
        help="increment verbose count (verbosity) by one. "\
                "Normal operation is to output one status line per file. "\
                "One -v option will give you information on what files are being"\
                " skipped and slightly more information at the end.  default=%default", action="count" ) 

    parser.add_option("-q", "--quiet", 
        action="store_const", const=0, dest="verbose_level", default=1, 
           help="Normal operation is to output one status line per file, status being \"inserted\", \"existing\", etc."
           " This option will prevent any output to stdout, Significant errors are still output to stderr.") 

 # -v, --verbose               increase verbosity
 # -q, --quiet                 suppress non-error messages
# This option increases the amount of information you are given during the transfer. 
# By default, rsync works silently. A single -v will give you information about what 
# files are being transferred and a brief summary at the end. 
# Two -v options will give you information on what files are being skipped and slightly more information at the end. More than two -v options should only be used if you are debugging rsync.        
        
    def _depth_callback(option, opt_str, value, parser): # , cls):
        if value == "None" or value == "none":
            setattr(parser.values, option.dest, None)
        else:
            try:
                setattr(parser.values, option.dest, int(value))
            except:
                raise OptionValueError("%s value must be integer or None. %s: %r received."
                                   % (option.dest, str(type(value)), value) )


    parser.add_option("-d", "--depth-limit", "--depth", dest="depth_limit", action="callback" , 
        callback=_depth_callback,
        help="limit recusion DEPTH. using DEPTH = 0 means process the directory only.  DEPTH=None means no depth limit (use with caution). "
        "Recursion is implied when any depth-limit is specified. default is %default.",
         metavar="DEPTH", type="string") 
# The remainder of the path with the year should be created later

# Get the command line arguments
usage = "usage: comics_downloader.py [-s|--strips strip names] [-t|--times dates (yyyymmdd)]"
parser = ArgumentParser(description=usage)

parser.add_option(
    "-s",
    "--strips",
    dest="strips",
    action="store",
    default=None,
    help="Download just the strips listed.  Use the ACMEReader short name "
    + "(the name of the comic's folder in ~/Documents/Comics/).",
)

parser.add_option(
    "-t",
    "--t",
    dest="time",
    action="store",
    default=None,
    help="Download strips starting from the given date, given in yyyymmdd "
    + "format. It goes back until it finds an already downloaded strip, or "
    + "until it reaches the start date for that strip.",
)

if len(sys.argv) > 1:
    if "-s" in sys.argv:
        #        while
        pass
    try:
Пример #6
0
def main():
    """
    main method that calls into all other methods
    """
    ret = 0
    runpythonunit = False
    runpythonunitfast = False
    bHelp = "Full test"
    fHelp = "Full tests, no network connection"
    des = "Command Line Options"
    phpunit_args = ""
    # builds up command line arguments
    try:
        from argparse import ArgumentParser

        parser = ArgumentParser(description=des)
        parser.add_argument("--unit", "-b", dest="u", action="store_true", help=bHelp)
        parser.add_argument("--unit-fast", "-f", dest="f", action="store_true", help=fHelp)
        args = parser.parse_args()

    except ImportError:  # Must be python 2.6 or lower
        from optparse import OptionParser

        parser = OptionParser(description=des)
        parser.add_option("--unit", "-b", dest="u", action="store_true", help=bHelp)
        parser.add_option("--unit-fast", "-f", dest="f", action="store_true", help=fHelp)
        args, blank = parser.parse_args()

    # parse command line options
    if args.u:
        runpythonunit = True
    if args.f:
        runpythonunitfast = True

    if len(sys.argv) < 2:
        parser.print_help()

    if runpythonunitfast == True:
        # get the location of current virtualenv
        local_python = get_python()
        if not os.path.exists(local_python):
            log("Error: virtualenv at (%s) does not exists." % (local_python))
            runpythonunit = False
            ret += 1
        # install dependancies and return deps that could not be installed
        ret += install_modules(tmpdir=local_python, nose=True)
        remove_module(tmpdir=local_python, module="viz3d")

    if runpythonunit == True:
        log("\n\n%s\n\n" % (bHelp))
        checkvirtualenv()
        # creates python virtualenv and returns the path to it
        tmpdir = createvirtualenv()
        # install dependancies and return deps that could not be installed
        dep_return = install_deps(tmpdir=tmpdir)
        # installs the python modules and runs the unit tests
        ret = ret + install_modules(tmpdir=tmpdir, dep_return=dep_return, nose=True)
        # clear out the temporary virtualenv
        log("\n\ncleaning up by removing dir (%s)\n\n" % (tmpdir))
        subprocess.call(shlex.split("rm -rf %s" % (tmpdir)))
        # make sure the return status is reported correctly back to buildbot or command line

    if not ret == 0:
        log(
            "Error: Process returned none zero exit status, ie some thing went wrong.  If you are confused then send email to info@jbbs-inc.com"
        )
        sys.exit(ret)