~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to daemons/poppy-upload.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-03-17 20:41:13 UTC
  • mfrom: (3277.1.4 launchpad-foobar2)
  • Revision ID: pqm@pqm.ubuntu.com-20060317204113-9841a4470db3611b
[r=jamesh] Mainline soyuz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
3
 
from canonical.poppy.server import run_server
4
 
from canonical.lucille.poppyinterface import PoppyInterface
5
 
 
6
3
import sys
7
4
import logging
 
5
import optparse
 
6
 
 
7
from canonical.poppy.server import run_server
 
8
from canonical.archivepublisher.poppyinterface import PoppyInterface
 
9
from canonical.launchpad.scripts import logger, logger_options
 
10
 
8
11
 
9
12
def main():
10
 
    args = sys.argv[1:]
 
13
 
 
14
    parser = optparse.OptionParser()
 
15
    logger_options(parser)
 
16
 
 
17
    parser.add_option("--cmd", action="store", metavar="CMD",
 
18
                      help="Run CMD after each upload completion")
 
19
 
 
20
    parser.add_option("--allow-user", action="store", metavar="USER",
 
21
                      default='ubuntu',
 
22
                      help="Username allowed to log in.")
 
23
 
 
24
    parser.add_option("--permissions", action="store", metavar="PERMS",
 
25
                      default='g+rwxs',
 
26
                      help="Permissions to chmod the targetfsroot with "
 
27
                      "before letting go of the directory.")
 
28
 
 
29
    options, args = parser.parse_args()
 
30
 
 
31
    log = logger(options, "poppy-upload")
 
32
 
11
33
    if len(args) != 2:
12
34
        print "usage: poppy-upload.py rootuploaddirectory port"
13
35
        return 1
 
36
 
14
37
    root, port = args
15
 
    host = "127.0.0.1"
 
38
    # host = "127.0.0.1"
 
39
    # host = "82.211.81.167" # Drescher's public IP
 
40
    host = "0.0.0.0"
16
41
    ident = "lucille upload server"
17
42
    numthreads = 4
18
43
 
19
 
    logger = logging.getLogger('Server')
20
 
    hdlr = logging.FileHandler('++lucilleupload.log')
21
 
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
22
 
    hdlr.setFormatter(formatter)
23
 
    logger.addHandler(hdlr)
24
 
    logger.setLevel(logging.DEBUG)
25
 
 
26
 
    iface = PoppyInterface(logger)
27
 
    
28
 
 
29
 
    run_server(root, host, int(port), ident, numthreads,
 
44
    iface = PoppyInterface(root, log, allow_user=options.allow_user,
 
45
                           cmd=options.cmd,
 
46
                           perms=options.permissions)
 
47
 
 
48
    run_server(host, int(port), ident, numthreads,
30
49
               iface.new_client_hook, iface.client_done_hook,
31
50
               iface.auth_verify_hook)
32
51
    return 0