Пример #1
0
def git():
    """Git entry point."""
    try:
        dispatch()
    except Exception, e:
        raise
        sys.exit(e)
Пример #2
0
def main():
    #import sys; print sys.argv
    dispatch(cmdtable={
       'dirs': (dirs_list, [], ''),
       'dirs-add': (dirs_add, [('u', 'user_home', False, 'Write into user home directory'),
                               ('r', 'root', '.', 'Root directory')],
                                "%name SOURCE DESTINATION"),
       #'dirs-remove': (dirs_show, []),
       #'dirs-suggest': (dirs_suggest, []),
       'show': (links_show, [], ''),
       'list': (links_list, [], ''),
       'reset': (links_reset, [('r', 'root', '.', 'Root directory'), 
                               ('v', 'verbose', False, 'Verboseness'),
                               ('f', 'force', False, 'Ignore warnings')], ''),
       'commit': (links_commit, [], ''),
    })
Пример #3
0
def main(args=None):
    """Called when run as a script."""
    _cmdtable = {
        'formats':(formats, _formats_options, '[OPTS] [INFILE]'),
        'query'  :(query,   _query_options,   '[OPTS] [INFILE [FIELDS]]'),
        '~test'  :(test,    _test_options,    '[OPTS]'),
        'convert':(convert, _convert_options, '[OPTS] [INFILE [OUTFILE]]'),
        'montage':(montage, _montage_options, '[OPTS] MONTAGE [INFILE [OUTFILE]]'),
        'rename' :(rename,  _rename_options,  '[OPTS] [INFILE [OUTFILE]]'),
        'reorder':(reorder, _reorder_options, '[OPTS] [INFILE [OUTFILE]]'),
        'block'  :(block,   _blocks_options,  '[OPTS] BLOCKSTR [INFILE [OUTFILE]]'),
        'lfilter':(lfilter, _lfilter_options, '[OPTS] [INFILE [OUTFILE]]'),
        'wfilter':(wfilter, _wfilter_options, '[OPTS] [INFILE [OUTFILE]]'),
        'dump'   :(dump,    _dump_options,    '[OPTS] [INFILE]'),
        'gen'    :(gen,     _gen_options,     '[OPTS] SIGNAL [OUTFILE]'),
    }
    return opster.dispatch(args=args,cmdtable=_cmdtable)
Пример #4
0
        try:
            from IPython import embed
        except ImportError:
            pass
        else:
            try:
                import sys
                if sys.platform == 'win32':
                    import pyreadline
            except ImportError:
                banner = ('There is IPython installed on your system, '
                          'but no pyreadline\n' + banner)
            else:
                embed(banner1=banner)
                return
        from code import interact
        interact(banner)


@command()
def runserver():
    from catalog import app, create
    create(CONFIG)
    app.debug = True
    app.run(host='0.0.0.0', port=8000)


if __name__ == '__main__':
    dispatch()
Пример #5
0
#!/usr/bin/env python

import sys
from opster import command, dispatch

@command(usage='[-h]')
def cmd():
    pass

if __name__ == "__main__":
    dispatch(sys.argv[1:], scriptname='newname')
Пример #6
0
      - ``UI.note`` is printed only if output is verbose
      - ``UI.write`` is printed in any case

    Additionally there is ``UI.warn`` method, which prints to stderr.
    '''

    options = [('v', 'verbose', False, 'enable additional output'),
               ('q', 'quiet', False, 'suppress output')]

    def __init__(self, verbose=False, quiet=False):
        self.verbose = verbose
        # disabling quiet in favor of verbose is more safe
        self.quiet = (not verbose and quiet)

    def write(self, *messages):
        for m in messages:
            sys.stdout.write(m)
        sys.stdout.flush()

    def warn(self, *messages):
        for m in messages:
            sys.stderr.write(m)
        sys.stderr.flush()

    info = lambda self, *m: not self.quiet and self.write(*m)
    note = lambda self, *m: self.verbose and self.write(*m)


if __name__ == '__main__':
    dispatch(globaloptions=UI.options, middleware=ui_middleware)
Пример #7
0
#!/usr/bin/env python

import sys

from opster import dispatch


cmd1opts = [('q', 'quiet', False, 'be quiet')]
def cmd1(**opts):
    if not opts['quiet']:
        print('Not being quiet!')

cmd2opts = [('v', 'verbose', False, 'be loud')]
def cmd2(arg, *args, **opts):
    print(arg)
    if opts['verbose']:
        for arg in args:
            print(arg)

cmdtable = {
    'cmd1':(cmd1, cmd1opts, '[-q|--quiet]'),
    'cmd2':(cmd2, cmd2opts, '[ARGS]'),
}

dispatch(sys.argv[1:], cmdtable)
Пример #8
0
def dispatch(package):
    """Process command line
    :param package: working package
    """
    opster.dispatch(middleware=functools.partial(middleware, package))
Пример #9
0
        sec, usec, n = header.unpack(data)
        curtime = sec + usec / 1000000.0
        if basetime is None:
            basetime = prevtime = curtime
        delay = curtime - prevtime
        prevtime = curtime
        data = script.read(n)
        if action == 'inspect':
            print '%8.4f %4d %s' % (delay, n, ` data[:40] `)
            continue
        if action == 'replay':
            time.sleep(delay / factor)
        elif action == 'typing':
            delay = 0
            if n == 1:
                delay = 0.2
            elif data.startswith('\r\n'):
                delay = 0.5
            if delay:
                os.system('import -window %s step%03d.gif' % (winid, stepnum))
                #time.sleep(delay)
                #print '-delay %d step%03d.gif' % (delay*100, stepnum),
                stepnum += 1

        sys.stdout.write(data)
        sys.stdout.flush()


if __name__ == '__main__':
    dispatch()
Пример #10
0
#!/usr/bin/env python

import sys
from opster import command, dispatch


@command(usage='[-h]')
def cmd():
    pass


if __name__ == "__main__":
    dispatch(sys.argv[1:], scriptname='newname')
Пример #11
0
 def opster(self, parameter_s=''):
     dispatch(parameter_s.split())
Пример #12
0
    """Generate requirements file for use with pip."""
    template = get_jinja_env().get_template('requirements.txt')
    write_text(output, template.render(fixtures=list_autoscan_fixtures(), **get_sources()))


@opster.command()
def setupcfg(output=('o', '/dev/stdout', 'the output setup.cfg file')):
    """Generate a setup configuration file."""
    template = get_jinja_env().get_template('setup.cfg')
    write_text(output, template.render(dirs=source_packages()))


@opster.command()
def pkgdirs(output=('o', '/dev/stdout', 'the output requirements file')):
    """Generate list of package directories."""
    write_text(output, u'\n'.join(source_packages()) + '\n')


@opster.command()
def examples(output=('o', '/dev/stdout', 'the output requirements file')):
    """Generate the examples page for Morepath docs."""
    template = get_jinja_env().get_template('examples.rst')
    setups = {s['name']: s for s in (read_setup(d) for d in get_subproject_dirs())}
    examples = [(label, link, 'https://pypi.python.org/pypi/' + label, setups[label]['description'])
                for label, link in get_sources()['examples']]
    write_text(output, template.render(examples=examples))


if __name__ == '__main__':
    sys.exit(opster.dispatch(scriptname='python -m ' + __package__))
Пример #13
0
    # genome identifiers.
    tsv = csv.writer(sys.stdout,
                     ["rsid", "chromosome", "position", "genotype"],
                     delimiter="\t")
    for (chrom, pos), candidates in snps.iteritems():
        if all(score <= threshold for score in candidates.itervalues()):
            logging.debug("Filtered out %r at chromosome %s, 1-position %i.",
                          candidates.items(), chrom, pos + 1)
            continue

        # Order candidates by quality and pick a single allele in the
        # monoploid case, or two alleles in the diploid one.
        candidates = sorted(candidates.iteritems(),
                            key=lambda (_, quality): quality,
                            reverse=True)
        genotype = "".join(base for (base, _) in candidates[:diploid + 1])
        tsv.writerow([g[chrom, pos].id,
                      chrom, str(pos + 1), genotype])

    # Should we store frequency of an SNP in a particular sample in the
    # index?
    return snps


if __name__ == "__main__":
    globaloptions = [
        ("i", "index-root", None, "path to 'consequnce' index"),
        ("v", "verbosity", 1, "verbosity level"),
    ]
    opster.dispatch(globaloptions=globaloptions)
Пример #14
0
#!/usr/bin/env python
"""My slightly more awesome script."""
import opster


@opster.command()
def sum(
    number=('n', 5, 'An interger.'),
    other=('', 1, 'Another interger.'),
):
    """Sum two integers."""
    print number + other


@opster.command()
def repeat(
    word=('w', 'London', 'The word to repeat.'),
    times=('t', 1, 'Number of time to repeat the word.'),
):
    """Repeat a word several times."""
    print ' '.join([word] * times)


if __name__ == '__main__':
    opster.dispatch()
Пример #15
0
from report import Report


@command()
def list(experimental=('', False, "include experimental reports"), ):
    """List available reports."""
    for k in Report.list():
        print(k)


@command()
def generate(
        name,
        output=('o', '/dev/stdout', "the output file"),
        periods=('p', 1, "the number of periods"),
        format=('f', ('text', 'html'), "the format of the report"),
        notify=('', [], "email address (can be repeated)"),
):
    """Generate a report."""
    try:
        report = Report(name, periods)
    except Exception as ex:
        raise command.Error(ex)
    report.generate(format, output)
    report.notify(notify)


if __name__ == '__main__':
    import sys
    sys.exit(dispatch())
Пример #16
0
    import fulda
    fulda.get(id)


@opster.command()
def cambridge(id=(
    "", "",
    "Id of the image to be downloaded (e. g. `PR-INC-00000-A-00007-00002-00888-000-00420`)"
)):
    """
	Downloads image from https://images.lib.cam.ac.uk
	"""
    import cambridge
    cambridge.get(id)


@opster.command()
def bodleian(id=(
    "", "",
    "Id of the image to be downloaded (e. g. `1273e6f5-ee79-4f6b-9014-a9065a93b9ff`)"
)):
    """
	Downloads image from https://digital.bodleian.ox.ac.uk
	"""
    import bodleian
    bodleian.get(id)


if __name__ == "__main__":
    opster.dispatch()
Пример #17
0
def start():
	opster.dispatch()
Пример #18
0
def git():
    """Git entry point."""
    try:
        dispatch()
    except Exception, e:
        sys.exit(e)
Пример #19
0
def cli():
    opster.dispatch()
Пример #20
0
      - ``UI.note`` is printed only if output is verbose
      - ``UI.write`` is printed in any case

    Additionally there is ``UI.warn`` method, which prints to stderr.
    '''

    options = [('v', 'verbose', False, 'enable additional output'),
               ('q', 'quiet', False, 'suppress output')]

    def __init__(self, verbose=False, quiet=False):
        self.verbose = verbose
        # disabling quiet in favor of verbose is more safe
        self.quiet = (not verbose and quiet)

    def write(self, *messages):
        for m in messages:
            sys.stdout.write(m)
        sys.stdout.flush()

    def warn(self, *messages):
        for m in messages:
            sys.stderr.write(m)
        sys.stderr.flush()

    info = lambda self, *m: not self.quiet and self.write(*m)
    note = lambda self, *m: self.verbose and self.write(*m)


if __name__ == '__main__':
    dispatch(globaloptions=UI.options, middleware=ui_middleware)
Пример #21
0
    def write(self, *messages):
        for m in messages:
            sys.stdout.write(m)
        sys.stdout.flush()

    def warn(self, *messages):
        for m in messages:
            sys.stderr.write(m)
        sys.stderr.flush()

    info = lambda self, *m: not self.quiet and self.write(*m)
    note = lambda self, *m: self.verbose and self.write(*m)


if __name__ == '__main__':
    dispatch(globaloptions=UI.options, middleware=ui_middleware)

########NEW FILE########
__FILENAME__ = multivalueserr
from __future__ import print_function
from opster import command

@command()
def test(arg1,
         b=1,
         opt=('o', False, 'some option'),
         bopt=('', 'bopt', 'another option'),
         *args):
    '''Simple command to test that it won't get multiple values for opt
    '''
    print('I work!', opt, bopt, arg1, b, args)