Beispiel #1
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()
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)
Beispiel #3
0
 def test_app_name(self):
     # This is going to be pytest as long as we invoke all these with
     # sys.interpreter -m pytest <source> since the __entry_point__ will
     # be detected as something like:
     # $HOME/workspace/science/3rdparty/python/pytest-2.0.2-py2.6.egg/pytest.pyc
     # or $HOME/.python-eggs/pants.pex/pytest-.../pytest.pyc
     assert app.name() == 'pytest'
     ALTERNATE_NAME = 'not_test_app_but_something_else'
     app.set_name(ALTERNATE_NAME)
     assert app.name() == ALTERNATE_NAME
     app.init(force_args=[])
     with pytest.raises(app.ApplicationError):
         app.set_name('anything')
Beispiel #4
0
 def test_app_name(self):
   # This is going to be pytest as long as we invoke all these with
   # sys.interpreter -m pytest <source> since the __entry_point__ will
   # be detected as something like:
   # $HOME/workspace/science/3rdparty/python/pytest-2.0.2-py2.6.egg/pytest.pyc
   # or $HOME/.python-eggs/pants.pex/pytest-.../pytest.pyc
   assert app.name() == 'pytest'
   ALTERNATE_NAME = 'not_test_app_but_something_else'
   app.set_name(ALTERNATE_NAME)
   assert app.name() == ALTERNATE_NAME
   app.init(force_args=[])
   with pytest.raises(app.ApplicationError):
     app.set_name('anything')
Beispiel #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()
# 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 apache.aurora.client.commands import (
    core,
    help,
    run,
    ssh,
)
from apache.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()
Beispiel #7
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()
Beispiel #8
0
app.register_commands_from(admin, help_commands, maintenance)
add_verbosity_options()


def main():
    app.help()


try:
    from apache.aurora.kerberos.auth_module import KerberosAuthModule
    register_auth_module(KerberosAuthModule())
except ImportError:
    # Use default auth implementation if kerberos is not available.
    pass

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

app.add_option('--bypass-leader-redirect',
               action='store_true',
               default=False,
               dest='bypass_leader_redirect',
               help='Bypass the scheduler\'s leader redirect filter')


def proxy_main():
    app.main()
# 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 apache.aurora.client.base import generate_terse_usage
from apache.aurora.client.commands import admin, help
from apache.aurora.client.options import add_verbosity_options

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


app.register_commands_from(admin, help)
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()