예제 #1
0
def configure_app(app):
    """ Register the application's options, set usage, and configure submodules. """

    app.set_name('starsystem')

    app.set_usage("{} [opts]\nOptions marked with * are required.".format(app.name()))

    app.add_option('-i', '--uri', dest='subsonic_uri',
                   help='* URI of the Subsonic server.')
    app.add_option('-u', '--user', dest='username',
                   help='* Username on the specified Subsonic server.')
    app.add_option('-t', '--token', dest='token',
                   help='* API token for the given username/salt combination\n'
                        'See: http://www.subsonic.org/pages/api.jsp')
    app.add_option('-s', '--salt', dest='salt',
                   help='* Salt used to generate the API token.')
    app.add_option('-p', '--path', dest='download_path',
                   help='* Path to the directory whither songs will be downloaded.')
    app.add_option('-S', '--since', dest='since', type='date',
                   help='Collect all songs since the specified date.')
    app.add_option('-I', '--insecure', dest='insecure', default=False, action="store_true",
                   help='Don\'t verify SSL certificates. Verification is enabled by default.')
    app.add_option('-g', '--gen-token-interactive', dest='gen_token', default=False,
                   action="store_true", help='Generate an API token interactively.')
    app.add_option('-v', '--debug', dest='debug', default=False,
                   action="store_true", help='Enable debug output.')

    app.set_option('twitter_common_log_disk_log_level', 'NONE', force=True)
예제 #2
0
def proxy_main():
    """Proxy main function.

    setuptools entrypoints with twitter.common.app is so awkward.
    """
    def main(_, opts):
        """Main"""

        if not opts.bucket:
            log.error('--bucket is required.')
            app.help()

        server = S3Web(bucket=opts.bucket,
                       prefix=opts.prefix,
                       access_key_id=opts.access_key_id,
                       secret_key=opts.secret_key)
        thread = ExceptionalThread(
            target=lambda: server.run(opts.listen,
                                      opts.port,
                                      server='cherrypy'))
        thread.daemon = True
        thread.start()

        log.info('Ready.')
        app.wait_forever()

    register_opts()
    app.set_usage(__doc__)
    app.set_option('twitter_common_log_stderr_log_level', 'google:INFO')
    app.set_name('s3webfront')
    app.main()
예제 #3
0
def generate_usage():
  usage = """
thermos

commands:
"""

  for (command, doc) in app.get_commands_and_docstrings():
    usage += '    ' + '%-10s' % command + '\t' + doc.split('\n')[0].strip() + '\n'
  app.set_usage(usage)
예제 #4
0
def generate_usage():
    usage = """
thermos

commands:
"""

    for (command, doc) in app.get_commands_and_docstrings():
        usage += "    " + "%-10s" % command + "\t" + doc.split("\n")[0].strip() + "\n"
    app.set_usage(usage)
예제 #5
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from twitter.common import app
from twitter.common.log.options import LogOptions

from apache.aurora.admin import help as help_commands
from apache.aurora.admin import admin, maintenance

from .help import add_verbosity_options, generate_terse_usage

app.register_commands_from(admin, help_commands, maintenance)
add_verbosity_options()


def main():
  app.help()


LogOptions.set_stderr_log_level('INFO')
LogOptions.disable_disk_logging()
app.set_name('aurora-admin')
app.set_usage(generate_terse_usage())


def proxy_main():
  app.main()
예제 #6
0
               metavar='PORT',
               default=DEFAULT_NG_PORT,
               type='int',
               help='to specify the port of the nailgun server (default is %default)')

app.add_option('--nailgun-help',
               dest='show_help',
               default=False,
               action='store_true',
               help='print this message and exit')

app.set_usage('''%(command)s class [--nailgun-options] [args]
          (to execute a class)
   or: %(command)s alias [options] [args]
          (to execute an aliased class)
   or: alias [options] [args]
          (to execute an aliased class, where "alias"
           is both the alias for the class and a symbolic
           link to the ng client)
''' % dict(command = sys.argv[0]))


def main(args):
  options = app.get_options()
  if options.show_help:
    app.help()

  if options.show_version or options.just_version:
    print >> sys.stdout, 'Python NailGun client version 0.0.1'
    if options.just_version:
      sys.exit(0)
예제 #7
0
    metavar='PORT',
    default=DEFAULT_NG_PORT,
    type='int',
    help='to specify the port of the nailgun server (default is %default)')

app.add_option('--nailgun-help',
               dest='show_help',
               default=False,
               action='store_true',
               help='print this message and exit')

app.set_usage('''%(command)s class [--nailgun-options] [args]
          (to execute a class)
   or: %(command)s alias [options] [args]
          (to execute an aliased class)
   or: alias [options] [args]
          (to execute an aliased class, where "alias"
           is both the alias for the class and a symbolic
           link to the ng client)
''' % dict(command=sys.argv[0]))


def main(args):
    options = app.get_options()
    if options.show_help:
        app.help()

    if options.show_version or options.just_version:
        print('Python NailGun client version 0.0.1', file=sys.stdout)
        if options.just_version:
            sys.exit(0)
예제 #8
0
# These are are side-effecting imports in that they register commands via
# app.command.  This is a poor code practice and should be fixed long-term
# with the creation of twitter.common.cli that allows for argparse-style CLI
# composition.
from twitter.aurora.client.commands import (
    core,
    help,
    run,
    ssh,
)
from twitter.aurora.client.options import add_verbosity_options

app.register_commands_from(core, run, ssh)
app.register_commands_from(help)
add_verbosity_options()


def main():
    app.help()


LogOptions.set_stderr_log_level('INFO')
LogOptions.disable_disk_logging()
app.set_name('aurora-client')
app.set_usage(generate_terse_usage())


def proxy_main():
    app.main()
    print '\nparsing %s\n' % arg
    tc = ThermosConfigLoader.load(arg)

    for task_wrapper in tc.tasks():
      task = task_wrapper.task
      if not task.has_name():
        print 'Found unnamed task!  Skipping...'
        continue

      print 'Task: %s [check: %s]' % (task.name(), task.check())
      if not task.processes():
        print '  No processes.'
      else:
        print '  Processes:'
        for proc in task.processes():
          print '    %s' % proc

      ports = task_wrapper.ports()
      if not ports:
        print '  No unbound ports.'
      else:
        print '  Ports:'
        for port in ports:
          print '    %s' % port

      print 'raw:'
      pprint.pprint(json.loads(task_wrapper.to_json()))

app.set_usage("%s config1 config2 ..." % app.name())
app.main()
예제 #10
0
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.job import Job
from jenkinsapi.exceptions import JenkinsAPIException
from jenkinsapi.exceptions import UnknownJob

import os
import sys

from twitter.common import app
from twitter.common import log
from twitter.common import dirutil

from twitter.common.log.options import LogOptions


app.set_usage("jenkins --[server|outdir|config]  [--job=[jobname]] [create|delete|show|enable|disable]")
app.add_option(
  "--server",
  default="ci.makewhat.is:8080",
  dest="server",
  help="jenkins server"
)
app.add_option(
  "--job",
  default=None,
  dest="job",
  help="job name"
)
app.add_option(
  "--config",
  default=None,
예제 #11
0
from __future__ import print_function

import binascii

from rainman.torrent import Torrent

from twitter.common import app


app.set_usage('''inspect_torrent <torrent filename>''')

def main(args, options):
  if len(args) != 1:
    app.help()

  torrent = Torrent.from_file(args[0])

  print('Torrent: %s' % args[0])
  print('Announce url: %s' % torrent.announce)

  print('Metainfo:')
  files = list(torrent.info.files(rooted_at=''))
  print('  name: %s' % torrent.info.name)
  print('  size: %d' % torrent.info.length)
  print('  files: %d' % len(files))
  print('  pieces: %d' % torrent.info.num_pieces)
  print('  piece size: %d' % torrent.info.piece_size)
  print()

  print('Hash manifest:')
  for index, hash in enumerate(torrent.info.piece_hashes):
예제 #12
0
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.job import Job
from jenkinsapi.exceptions import JenkinsAPIException
from jenkinsapi.exceptions import UnknownJob

import os
import sys

from twitter.common import app
from twitter.common import log
from twitter.common import dirutil

from twitter.common.log.options import LogOptions

app.set_usage(
    "jenkins --[server|outdir|config]  [--job=[jobname]] [create|delete|show|enable|disable]"
)
app.add_option("--server",
               default="ci.makewhat.is:8080",
               dest="server",
               help="jenkins server")
app.add_option("--job", default=None, dest="job", help="job name")
app.add_option("--config", default=None, dest="config", help="config path")
app.add_option("--config_dir",
               default=None,
               dest="config_dir",
               help="config directory")
app.add_option("--outdir",
               default=None,
               dest="outdir",
               help="config dump output path")
예제 #13
0
        tc = ThermosConfigLoader.load(arg)

        for task_wrapper in tc.tasks():
            task = task_wrapper.task
            if not task.has_name():
                print('Found unnamed task!  Skipping...')
                continue

            print('Task: %s [check: %s]' % (task.name(), task.check()))
            if not task.processes():
                print('  No processes.')
            else:
                print('  Processes:')
                for proc in task.processes():
                    print('    %s' % proc)

            ports = task_wrapper.ports()
            if not ports:
                print('  No unbound ports.')
            else:
                print('  Ports:')
                for port in ports:
                    print('    %s' % port)

            print('raw:')
            pprint.pprint(json.loads(task_wrapper.to_json()))


app.set_usage("%s config1 config2 ..." % app.name())
app.main()
예제 #14
0
import os

from rainman.metainfo import MetaInfoBuilder
from rainman.torrent import Torrent

from twitter.common import app, log


app.set_usage(
    """
make_torrent [-r relpath] <torrent filename> <tracker url> path1 path2 ...

Paths may be either filenames or directories.  If a directory is specified,
its contents will be recursively walked and stored in the torrent.

If relpath is specified, all files in the torrent will be relative to that
path.
"""
)

app.add_option("-r", dest="relpath", default=None, help="The relative path for all files within the torrent.")


def main(args, options):
    if len(args) <= 2:
        app.help()

    torrent_name, tracker = args[0:2]

    filelist = []
예제 #15
0

def _format_instances(instances):
  return ', '.join(
      '%s:%s' % (i.serviceEndpoint.host, i.serviceEndpoint.port)
      for i in instances)


def main(args, options):
  if not args:
    app.error('expected at least one ServerSet endpoint')

  def changed(endpoint, old, new):
    print '%s changed:' % endpoint
    print '  old:', _format_instances(old)
    print '  new:', _format_instances(new)
    print

  print 'Watching ServerSet endpoints. Hit ^C to exit.'
  print

  endpoints = []
  for arg in args:
    endpoints.append(ServerSetClient(arg, watcher=changed))
  while True:
    raw_input()


app.set_usage('%prog <endpoint> ...')
app.main()
예제 #16
0
from twitter.common.zookeeper.serversets import ServerSetClient


def _format_instances(instances):
    return ', '.join('%s:%s' % (i.serviceEndpoint.host, i.serviceEndpoint.port)
                     for i in instances)


def main(args, options):
    if not args:
        app.error('expected at least one ServerSet endpoint')

    def changed(endpoint, old, new):
        print '%s changed:' % endpoint
        print '  old:', _format_instances(old)
        print '  new:', _format_instances(new)
        print

    print 'Watching ServerSet endpoints. Hit ^C to exit.'
    print

    endpoints = []
    for arg in args:
        endpoints.append(ServerSetClient(arg, watcher=changed))
    while True:
        raw_input()


app.set_usage('%prog <endpoint> ...')
app.main()