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()