My favorites | Sign in
Project Home Issues Source
Repository:
Checkout   Browse   Changes   Clones  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3

def fix_etree_to_string():
'''Fix xml.etree.ElementTree.tostring for python < 3.2'''
import sys
if sys.version_info.major >= 3 and sys.version_info.minor >= 2:
return

from xml.etree import ElementTree as etree
_etree_tostring_original = etree.tostring
def _etree_tostring_wrapper(*args, **kwargs):
if kwargs.get('encoding') == 'unicode':
del kwargs['encoding']
return _etree_tostring_original(*args, **kwargs)
etree.tostring = _etree_tostring_wrapper

def main():
from argparse import ArgumentParser
parser = ArgumentParser(
usage='%(prog)s [options] [PATH]',
description='Serves media from the given PATH over UPnP-AV and DLNA.')
parser.add_argument(
'-p', '--port', type=int, default=1337,
help='media server listen PORT')
parser.add_argument(
'--logging_conf', '--logging-conf',
help='Path of Python logging configuration file')
parser.add_argument('--notify-interval', '-n', type=int, default=895,
help='time in seconds between server advertisements on the network')
parser.add_argument('path', nargs='?')
namespace = parser.parse_args()

import logging, logging.config
if namespace.logging_conf is None:
formatter = logging.Formatter(
'%(asctime)s.%(msecs)03d;%(levelname)s;%(name)s;%(message)s',
datefmt='%H:%M:%S')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger.addHandler(handler)
else:
logging.config.fileConfig(namespace.logging_conf, disable_existing_loggers=False)
logger = logging.getLogger('pydlnadms.main')

path = namespace.path
if path is None:
import os
path = os.curdir
import os.path
path = os.path.normpath(path)

fix_etree_to_string()

from pydlnadms import DigitalMediaServer
DigitalMediaServer(namespace.port, path, notify_interval=namespace.notify_interval)

if __name__ == '__main__':
main()

Change log

f262cddc6d7d by Matt Joiner <anacrolix> on May 22, 2012   Diff
Fix crash when using --logging-conf.
Go to: 
Project members, sign in to write a code review

Older revisions

9da8fc1aa49e by Matt Joiner <anacrolix> on May 22, 2012   Diff
Fix crash when printing command line
options.
29619f58b44d by Matt Joiner <anacrolix> on Jan 21, 2012   Diff
Missing import when no path specified,
patch by Thomas Troeger
<tstroege@gmx.de>
ae47431d0b36 by Matt Joiner <anacrolix> on Nov 13, 2011   Diff
Adjust default logging levels.
All revisions of this file

File info

Size: 2120 bytes, 60 lines
Powered by Google Project Hosting