blob: 1d2b53e29f68fa9e334100603072c640aac29fc2 (
plain)
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
|
from git_tftpd.backend import GitBackend
from git_tftpd.protocol import TFTPProtocol
from twisted.python import usage
from twisted.plugin import IPlugin
from twisted.application.service import IServiceMaker
from twisted.application import internet
from zope.interface import implements
class Options(usage.Options):
optParameters = [
['port', 'p', 50069, 'The port number to listen on.'],
['repo', 'r', None, 'The path to the git repo. [required]'],
]
class MyServiceMaker(object):
implements(IServiceMaker, IPlugin)
tapname = 'git-tftpd'
description = 'A tftp server, that commits the files into a git repo.'
options = Options
def makeService(self, options):
if options['repo'] is None:
raise usage.UsageError, 'Missing required argument'
backend = GitBackend(options['repo'])
return internet.UDPServer(int(options["port"]), TFTPProtocol(backend))
serviceMaker = MyServiceMaker()
|