summaryrefslogtreecommitdiff
path: root/debian/patches/0100-config.diff
blob: bb07520198c5f68082bcf493cc60dba1f5c32017 (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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Description: add loading config from every path
 Add loading config from ervery path
 Separation data / program
Author: Jörg Frings-Fürst <jff@jff-webhosting.net>
Last-Update: 2014-05-12
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: trunk/mwc.py
===================================================================
--- trunk.orig/mwc.py
+++ trunk/mwc.py
@@ -316,7 +316,7 @@ def pollWebsites():
 
 if __name__ == "__main__":
 
-        configMod = 'config'
+        configMod = '/etc/mwc/mwc-config'
         dryrun = None
 
         try:
@@ -332,9 +332,24 @@ if __name__ == "__main__":
                         configMod = arg
                 elif opt in ('-d', '--dry-run'):
                         dryrun = arg
-
-        config = importlib.import_module(configMod)
-
+	# 
+	# add code to load config from nonsystem path
+	# and change to datadir
+	#
+        try:
+            path = os.path.dirname(configMod)
+            fullname = os.path.basename(configMod)
+            sys.path.append(path)
+            config = importlib.import_module(fullname)
+        except: 
+            print('Error: loading config')
+            sys.exit(2)
+        try:
+            os.chdir(config.datadir)
+        except: 
+            print('Error: datadir not found')
+            sys.exit(3)
+    
         if dryrun:
                 for site in config.sites:
                         if site['shortname'] == dryrun:
Index: trunk/config_template.py
===================================================================
--- trunk.orig/config_template.py
+++ trunk/config_template.py
@@ -1,5 +1,3 @@
-import os.path
-
 # Copyright: (2013-2014) Michael Till Beck <Debianguru@gmx.de>
 # License: GPL-2.0+
 
@@ -44,11 +42,11 @@ sender = 'me@mymail.com'
 smtphost = 'mysmtpprovider.com'
 useTLS = True
 smtpport = 587
-smtpusername = sender
+smtpusername = 'sender'
 smtppwd = 'mypassword'
 receiver = 'me2@mymail.com'
 
-os.chdir('/var/cache/mwc')
+datadir'/var/cache/mwc'
 
 enableRSSFeed = True
 rssfile = 'feed.xml'
Index: trunk/mwcfeedserver.py
===================================================================
--- trunk.orig/mwcfeedserver.py
+++ trunk/mwcfeedserver.py
@@ -6,6 +6,7 @@
 import http.server
 import socketserver
 import importlib
+import os
 import sys
 import getopt
 
@@ -31,13 +32,26 @@ for opt, arg in opts:
         elif opt in ('-p', '--port'):
                 port = int(arg)
 
-config = importlib.import_module(configMod)
-
+#
+# add code to load config from nonsystem path
+# and change to datadir
+#
+try:
+	path = os.path.dirname(configMod)
+	fullname = os.path.basename(configMod)
+	sys.path.append(path)
+	config = importlib.import_module(fullname)
+except:
+	print('Error: loading config')
+	sys.exit(2)
 
 handler = http.server.SimpleHTTPRequestHandler
 
 httpd = socketserver.TCPServer((bind, port), handler)
 
 print('Bond to ' + bind + ', listening on port ' + str(port))
-httpd.serve_forever()
-
+try:
+	httpd.serve_forever()
+except KeyboardInterrupt:
+	pass
+httpd.server_close()