summaryrefslogtreecommitdiffstats
path: root/src/twisted/plugins/git_tftpd_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/twisted/plugins/git_tftpd_plugin.py')
-rw-r--r--src/twisted/plugins/git_tftpd_plugin.py32
1 files changed, 32 insertions, 0 deletions
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()