Пример #1
0
def publish_egg(path,
                version,
                comment,
                eggfile,
                host='localhost',
                port=server.DEFAULT_PORT):
    """
    Publish egg on server at `host`:`port` under `path` and `version` with
    `comment` given `eggfile`.

    path: string
        Component path to be published.

    version: string
        Version to be published.

    comment: string
        Description of this version of this component.

    eggfile: string
        Name of egg file to publish.

    host: string
        Host name of server to publish to.

    port: int
        Port number of server to publish to.
    """
    try:
        _client = client.Client(host, port)
    except Exception as exc:
        raise RuntimeError("Can't connect to %s:%d: %s" % (host, port, exc))

    _client.publish_egg(path, version, comment, eggfile)
Пример #2
0
def main():  # pragma no cover
    """
    Publish a component.

    Usage: python publish.py --path=path --version=ver [--comment=text]{--egg=filename | --file=filename [--classname=classname]}[--host=address][--port=number][--list]

    --path: string
        Path to publish under.

    --version: string
        Version to publish under.

    --comment: string
        Version comment.

    --egg: string
        Egg file containing component to publish.

    --file: string
        Python file containing component to publish.

    --classname: string
        Name of component class.

    --host: string
        IPv4 address or hostname. Default is 'localhost'.

    --port: int
        Server port (default 1835).

    --list:
        List existing versions for "path", do not publish.
    """
    parser = optparse.OptionParser()
    parser.add_option('--path',
                      action='store',
                      type='string',
                      help='path to publish under')
    parser.add_option('--version',
                      action='store',
                      type='string',
                      help='version to publish under')
    parser.add_option('--comment',
                      action='store',
                      type='string',
                      help='version description')
    parser.add_option('--egg',
                      action='store',
                      type='string',
                      help='egg file containing component to publish')
    parser.add_option('--file',
                      action='store',
                      type='string',
                      help='python file containing component to publish')
    parser.add_option('--classname',
                      action='store',
                      type='string',
                      help='name of component class')
    parser.add_option('--host',
                      action='store',
                      type='string',
                      default='localhost',
                      help='host to connect to')
    parser.add_option('--port',
                      action='store',
                      type='int',
                      default=server.DEFAULT_PORT,
                      help='port to connect to')
    parser.add_option('--list',
                      action='store_true',
                      help='list existing versions for "path", do not publish')

    options, arguments = parser.parse_args()
    if arguments:
        parser.print_help()
        sys.exit(1)

    if not options.path:
        print '--path is required'
        sys.exit(1)

    if options.list:
        try:
            _client = client.Client(options.host, options.port)
        except Exception as exc:
            print "Can't connect to %s:%d: %s" \
                  % (options.host, options.port, exc)
            sys.exit(1)
        for version in _client.versions(options.path):
            print version
        sys.exit(0)

    if not options.version:
        print '--version is required'
        sys.exit(1)

    if options.egg:
        if not os.path.exists(options.egg):
            print 'Egg file %r does not exist' % options.egg
            sys.exit(1)
        try:
            publish_egg(options.path, options.version, options.comment,
                        options.egg, options.host, options.port)
        except Exception as exc:
            print exc
            sys.exit(1)
    else:
        if not options.file:
            print '--file is required if --egg is not used'
            sys.exit(1)

        if not os.path.exists(options.file):
            print 'Python file %r does not exist' % options.file
            sys.exit(1)

        if not options.classname:
            print '--classname is required'
            sys.exit(1)

        try:
            publish_class(options.path, options.version, options.comment,
                          options.file, options.classname, options.host,
                          options.port)
        except Exception as exc:
            print exc
            sys.exit(1)
Пример #3
0
 def __init__(self, host='localhost', port=server.DEFAULT_PORT):
     super(ASFactory, self).__init__()
     self._host = host
     self._port = port
     self._client = client.Client(host, port)
Пример #4
0
 def __init__(self, host='localhost', port=server.DEFAULT_PORT):
     super(ASFactory, self).__init__()
     self._host = host
     self._port = port
     trace = bool(os.environ.get('AS_TRACE_FACTORY'))
     self._client = client.Client(host, port, trace)