Beispiel #1
0
def run_pootle(options, args):
    """Run the requested action."""
    if options.action == 'runwebserver':
        handler = StaticFilesHandler(WSGIHandler())
        wsgi.launch_server('0.0.0.0', options.port, handler)
    elif options.action == 'refreshstats':
        call_command('refresh_stats')
    elif options.action == 'version':
        display_versions()
def run_pootle(options, args):
    """Run the requested action."""
    if options.action == "runwebserver":
        path = django.__path__[0] + "/contrib/admin/media"
        handler = AdminMediaHandler(WSGIHandler(), path)
        wsgi.launch_server("0.0.0.0", options.port, handler)
    elif options.action == "refreshstats":
        call_command("refresh_stats")
    elif options.action == "version":
        display_versions()
def run_pootle(options, args):
    """Run the requested action."""
    if options.action == 'runwebserver':
        path = django.__path__[0] + '/contrib/admin/media'
        handler = AdminMediaHandler(WSGIHandler(), path)
        wsgi.launch_server('0.0.0.0', options.port, handler)
    elif options.action == 'refreshstats':
        call_command('refresh_stats')
    elif options.action == 'version':
        display_versions()
Beispiel #4
0
def main():
    parser = OptionParser()
    parser.add_option("-d", "--tmdb", dest="tmdbfile", default=":memory:",
                      help="translation memory database file")
    parser.add_option("-f", "--import-translation-file", dest="tmfiles",
                      action="append",
                      help="translation file to import into the database")
    parser.add_option("-t", "--import-target-lang", dest="target_lang",
                      help="target language of translation files")
    parser.add_option("-s", "--import-source-lang", dest="source_lang",
                      help="source language of translation files")
    parser.add_option("-b", "--bind", dest="bind", default="localhost",
                      help="adress to bind server to (default: localhost)")
    parser.add_option("-p", "--port", dest="port", type="int", default=8888,
                      help="port to listen on (default: 8888)")
    parser.add_option("--max-candidates", dest="max_candidates", type="int",
                      default=3,
                      help="Maximum number of candidates")
    parser.add_option("--min-similarity", dest="min_similarity", type="int",
                      default=75,
                      help="minimum similarity")
    parser.add_option("--max-length", dest="max_length", type="int",
                      default=1000,
                      help="Maxmimum string length")
    parser.add_option("--debug", action="store_true", dest="debug",
                      default=False,
                      help="enable debugging features")

    (options, args) = parser.parse_args()

    #setup debugging
    format = '%(asctime)s %(levelname)s %(message)s'
    level = options.debug and logging.DEBUG or logging.WARNING
    if options.debug:
        format = '%(levelname)7s %(module)s.%(funcName)s:%(lineno)d: %(message)s'
        import sys
        if sys.version_info[:2] < (2, 5):
            format = '%(levelname)7s %(module)s [%(filename)s:%(lineno)d]: %(message)s'
    else:
        try:
            import psyco
            psyco.full()
        except Exception:
            pass

    logging.basicConfig(level=level, format=format)

    application = TMServer(options.tmdbfile, options.tmfiles,
                           max_candidates=options.max_candidates,
                           min_similarity=options.min_similarity,
                           max_length=options.max_length,
                           prefix="/tmserver",
                           source_lang=options.source_lang,
                           target_lang=options.target_lang)
    wsgi.launch_server(options.bind, options.port, application.rest)
Beispiel #5
0
def main():
    parser = OptionParser()
    parser.add_option("-d", "--tmdb", dest="tmdbfile", default=":memory:",
                      help="translation memory database file")
    parser.add_option("-f", "--import-translation-file", dest="tmfiles",
                      action="append",
                      help="translation file to import into the database")
    parser.add_option("-t", "--import-target-lang", dest="target_lang",
                      help="target language of translation files")
    parser.add_option("-s", "--import-source-lang", dest="source_lang",
                      help="source language of translation files")
    parser.add_option("-b", "--bind", dest="bind", default="localhost",
                      help="adress to bind server to (default: localhost)")
    parser.add_option("-p", "--port", dest="port", type="int", default=8888,
                      help="port to listen on (default: 8888)")
    parser.add_option("--max-candidates", dest="max_candidates", type="int",
                      default=3,
                      help="Maximum number of candidates")
    parser.add_option("--min-similarity", dest="min_similarity", type="int",
                      default=75,
                      help="minimum similarity")
    parser.add_option("--max-length", dest="max_length", type="int",
                      default=1000,
                      help="Maxmimum string length")
    parser.add_option("--debug", action="store_true", dest="debug",
                      default=False,
                      help="enable debugging features")

    (options, args) = parser.parse_args()

    #setup debugging
    format = '%(asctime)s %(levelname)s %(message)s'
    level = options.debug and logging.DEBUG or logging.WARNING
    if options.debug:
        format = '%(levelname)7s %(module)s.%(funcName)s:%(lineno)d: %(message)s'
        import sys
        if sys.version_info[:2] < (2, 5):
            format = '%(levelname)7s %(module)s [%(filename)s:%(lineno)d]: %(message)s'

    logging.basicConfig(level=level, format=format)

    application = TMServer(options.tmdbfile, options.tmfiles,
                           max_candidates=options.max_candidates,
                           min_similarity=options.min_similarity,
                           max_length=options.max_length,
                           prefix="/tmserver",
                           source_lang=options.source_lang,
                           target_lang=options.target_lang)
    wsgi.launch_server(options.bind, options.port, application.rest)
Beispiel #6
0
def main():
    parser = ArgumentParser()
    parser.add_argument("-d", "--tmdb", dest="tmdbfile", default=":memory:",
                        help="translation memory database file")
    parser.add_argument("-f", "--import-translation-file", dest="tmfiles",
                        action="append",
                        help="translation file to import into the database")
    parser.add_argument("-t", "--import-target-lang", dest="target_lang",
                        help="target language of translation files")
    parser.add_argument("-s", "--import-source-lang", dest="source_lang",
                        help="source language of translation files")
    parser.add_argument("-b", "--bind", dest="bind", default="localhost",
                        help="address to bind server to (default: %(default)s)")
    parser.add_argument("-p", "--port", dest="port", type=int, default=8888,
                        help="port to listen on (default: %(default)s)")
    parser.add_argument("--max-candidates", dest="max_candidates", type=int,
                        default=3,
                        help="Maximum number of candidates")
    parser.add_argument("--min-similarity", dest="min_similarity", type=int,
                        default=75,
                        help="minimum similarity")
    parser.add_argument("--max-length", dest="max_length", type=int,
                        default=1000,
                        help="Maxmimum string length")
    parser.add_argument("--debug", action="store_true", dest="debug",
                        default=False,
                        help="enable debugging features")

    args = parser.parse_args()

    #setup debugging
    format = '%(asctime)s %(levelname)s %(message)s'
    level = args.debug and logging.DEBUG or logging.WARNING
    if args.debug:
        format = '%(levelname)7s %(module)s.%(funcName)s:%(lineno)d: %(message)s'

    logging.basicConfig(level=level, format=format)

    application = TMServer(args.tmdbfile, args.tmfiles,
                           max_candidates=args.max_candidates,
                           min_similarity=args.min_similarity,
                           max_length=args.max_length,
                           prefix="/tmserver",
                           source_lang=args.source_lang,
                           target_lang=args.target_lang)
    wsgi.launch_server(args.bind, args.port, application.rest)
Beispiel #7
0
def main():
    parser = ArgumentParser()
    parser.add_argument(
        "-d",
        "--tmdb",
        dest="tmdbfile",
        default=":memory:",
        help="translation memory database file",
    )
    parser.add_argument(
        "-f",
        "--import-translation-file",
        dest="tmfiles",
        action="append",
        help="translation file to import into the database",
    )
    parser.add_argument(
        "-t",
        "--import-target-lang",
        dest="target_lang",
        help="target language of translation files",
    )
    parser.add_argument(
        "-s",
        "--import-source-lang",
        dest="source_lang",
        help="source language of translation files",
    )
    parser.add_argument(
        "-b",
        "--bind",
        dest="bind",
        default="localhost",
        help="address to bind server to (default: %(default)s)",
    )
    parser.add_argument(
        "-p",
        "--port",
        dest="port",
        type=int,
        default=8888,
        help="port to listen on (default: %(default)s)",
    )
    parser.add_argument(
        "--max-candidates",
        dest="max_candidates",
        type=int,
        default=3,
        help="Maximum number of candidates",
    )
    parser.add_argument(
        "--min-similarity",
        dest="min_similarity",
        type=int,
        default=75,
        help="minimum similarity",
    )
    parser.add_argument(
        "--max-length",
        dest="max_length",
        type=int,
        default=1000,
        help="Maxmimum string length",
    )
    parser.add_argument(
        "--debug",
        action="store_true",
        dest="debug",
        default=False,
        help="enable debugging features",
    )

    args = parser.parse_args()

    # setup debugging
    format = "%(asctime)s %(levelname)s %(message)s"
    level = logging.DEBUG if args.debug else logging.WARNING
    if args.debug:
        format = "%(levelname)7s %(module)s.%(funcName)s:%(lineno)d: %(message)s"

    logging.basicConfig(level=level, format=format)

    application = TMServer(
        args.tmdbfile,
        args.tmfiles,
        max_candidates=args.max_candidates,
        min_similarity=args.min_similarity,
        max_length=args.max_length,
        prefix="/tmserver",
        source_lang=args.source_lang,
        target_lang=args.target_lang,
    )
    wsgi.launch_server(args.bind, args.port, application.rest)