source: TI05-delivery/trunk/examples/deliveryd.py @ 1541

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/trunk/examples/deliveryd.py
Revision 1541, 1.1 KB checked in by spascoe, 13 years ago (diff)

Major directory structure reorganisation.

The python source tree is now divided into 3 components: common,
server and client. Each component has it's own setup.py.

Do "python setup.py bdist_egg" to create 3 eggs for each component.

Some things in the distribution are now out of sync (e.g. documentation) but
the test cases work (I havn't tried the remote test cases).

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2"""A very simple example of a server.
3
4@author Stephen pascoe
5"""
6
7import sys, os, syslog, stat, time, signal
8from glob import glob
9import re, tempfile, getopt
10
11import logging
12logging.basicConfig(level=logging.DEBUG, filename='./bbftpd.log')
13logger = logging.getLogger('ndg.delivery.server')
14
15import ndg.delivery.server.pybbftp as server
16from ndg.delivery.common.auth_plugin import *
17
18
19print '''
20===================================
21NDG Delivery Service example server
22===================================
23'''
24
25def after_fork_hook():
26    logging.root.handlers = []
27    logging.basicConfig(level=logging.DEBUG, filename='./bbftpd.log')
28    logger.info('Called after_fork_hook')
29
30logfile = './bbftpd.log'
31n = len(open(logfile).readlines())
32c = server.ServerConnector()
33pid = server.start(AuthHandler(c), ['-l', 'DEBUG'])
34print 'Server process started at pid = %d' % pid
35print 'Monitoring %s' % logfile
36
37try:
38    while 1:
39        newlines = open(logfile).readlines()[n:]
40        n += len(newlines)
41        for line in newlines:
42            print line,
43        time.sleep(2)
44except:
45    os.kill(pid, signal.SIGTERM)
46    print 'Server process killed'
Note: See TracBrowser for help on using the repository browser.