From b5e718d6f4d37ca31c12eef603c6199c4b89a046 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 28 Aug 2015 02:43:22 +0200 Subject: Initial commit --- src/twisted/plugins/git_tftpd_plugin.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/twisted/plugins/git_tftpd_plugin.py (limited to 'src/twisted/plugins/git_tftpd_plugin.py') diff --git a/src/twisted/plugins/git_tftpd_plugin.py b/src/twisted/plugins/git_tftpd_plugin.py new file mode 100644 index 0000000..1d2b53e --- /dev/null +++ b/src/twisted/plugins/git_tftpd_plugin.py @@ -0,0 +1,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() -- cgit v1.2.3-1-g7c22