Tue, 04 Nov 2014 15:59:20 +0200
- added the .changeset (aka .cset or .rev) command to get revision info
0 | 1 | #!/usr/bin/env python |
2 | ''' | |
25
9fa1df6113c4
- changed the copyright line to use my proper legal name instead of my common calling name
Santeri Piippo <crimsondusk64@gmail.com>
parents:
24
diff
changeset
|
3 | Copyright 2014 Teemu Piippo |
0 | 4 | All rights reserved. |
5 | ||
6 | Redistribution and use in source and binary forms, with or without | |
7 | modification, are permitted provided that the following conditions | |
8 | are met: | |
9 | ||
10 | 1. Redistributions of source code must retain the above copyright | |
11 | notice, this list of conditions and the following disclaimer. | |
12 | 2. Redistributions in binary form must reproduce the above copyright | |
13 | notice, this list of conditions and the following disclaimer in the | |
14 | documentation and/or other materials provided with the distribution. | |
15 | 3. The name of the author may not be used to endorse or promote products | |
16 | derived from this software without specific prior written permission. | |
17 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
19 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
21 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
23 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
27 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | ''' | |
29 | ||
30 | import asyncore | |
31 | import socket | |
32 | import time | |
33 | import sys | |
34 | import traceback | |
35 | import re | |
36 | import json | |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
37 | import urllib |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
38 | import urllib2 |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
39 | import hgapi |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
40 | import os |
15
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
41 | import suds |
23
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
42 | import math |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
43 | from datetime import datetime |
0 | 44 | |
45 | try: | |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
46 | uid = os.geteuid() |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
47 | except: |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
48 | uid = -1 |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
49 | |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
50 | if uid == 0 and raw_input ('Do you seriously want to run cobalt as root? [y/N] ') != 'y': |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
51 | quit() |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
52 | |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
53 | print 'Loading configuration...' |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
54 | try: |
0 | 55 | with open ('cobalt.json', 'r') as fp: |
56 | g_config = json.loads (fp.read()) | |
57 | except IOError as e: | |
58 | print 'couldn\'t open cobalt.json: %s' % e | |
59 | quit() | |
60 | ||
61 | g_admins = g_config['admins'] | |
62 | g_mynick = g_config['nickname'] | |
63 | ||
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
64 | g_idgamesSearchURL = 'http://www.doomworld.com/idgames/api/api.php?action=search&query=%s&type=title&sort=date&out=json' |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
65 | g_BotActive = False |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
66 | |
0 | 67 | # |
68 | # SOAP stuff | |
69 | # | |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
70 | suds_active = False |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
71 | |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
72 | try: |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
73 | print 'Initializing MantisBT connection...' |
15
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
74 | suds_import = suds.xsd.doctor.Import ('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') |
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
75 | suds_client = suds.client.Client ('https://zandronum.com/tracker/api/soap/mantisconnect.php?wsdl', plugins=[suds.xsd.doctor.ImportDoctor (suds_import)]) |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
76 | suds_active = True |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
77 | except Exception as e: |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
78 | print 'Failed to establish MantisBT connection: ' + `e` |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
79 | pass |
0 | 80 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
81 | btannounce_active = False |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
82 | btannounce_timeout = 0 |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
83 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
84 | def save_config(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
85 | with open ('cobalt.json', 'w') as fp: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
86 | json.dump (g_config, fp, sort_keys = True, indent = 4) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
87 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
88 | def cfg (key, default): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
89 | if not hasattr (g_config, key): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
90 | g_config[key] = default |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
91 | save_config() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
92 | return default |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
93 | return g_config[key] |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
94 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
95 | def bt_updatechecktimeout(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
96 | global btannounce_timeout |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
97 | btannounce_timeout = time.time() + (cfg ('btlatest_checkinterval', 5) * 60) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
98 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
99 | def bool_from_string (value): |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
100 | if value != 'true' and value != 'false': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
101 | raise logical_exception ('expected true or false for value') |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
102 | return True if value == 'true' else False |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
103 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
104 | if suds_active: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
105 | try: |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
106 | sys.stdout.write ('Retrieving latest tracker ticket... ') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
107 | btannounce_id = suds_client.service.mc_issue_get_biggest_id (g_config['trackeruser'], g_config['trackerpassword'], 0) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
108 | btannounce_active = True |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
109 | bt_updatechecktimeout() |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
110 | print btannounce_id |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
111 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
112 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
113 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
114 | def bt_getissue(ticket): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
115 | global suds_client |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
116 | global g_config |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
117 | return suds_client.service.mc_issue_get (g_config['trackeruser'], g_config['trackerpassword'], ticket) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
118 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
119 | def bt_checklatest(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
120 | global btannounce_timeout |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
121 | global btannounce_id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
122 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
123 | if time.time() >= btannounce_timeout: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
124 | bt_updatechecktimeout() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
125 | newid = btannounce_id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
126 | try: |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
127 | newid = suds_client.service.mc_issue_get_biggest_id (g_config['trackeruser'], g_config['trackerpassword'], 0) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
128 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
129 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
130 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
131 | while newid > btannounce_id: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
132 | try: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
133 | btannounce_id += 1 |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
134 | data = bt_getissue (btannounce_id) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
135 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
136 | for client in g_clients: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
137 | client.announce_ticket (data) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
138 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
139 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
140 | |
0 | 141 | # |
142 | # irc_client flags | |
143 | # | |
144 | CLIF_CONNECTED = (1 << 1) | |
145 | ||
146 | # | |
147 | # List of all clients | |
148 | # | |
149 | g_clients = [] | |
150 | ||
151 | class channel (object): | |
152 | name = "" | |
153 | password = "" | |
154 | ||
155 | def __init__ (self, name): | |
156 | self.name = name | |
157 | ||
158 | # | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
159 | # Prints a line to log channel(s) |
0 | 160 | # |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
161 | def chanlog (line): |
0 | 162 | for client in g_clients: |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
163 | if not client.flags & CLIF_CONNECTED: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
164 | continue |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
165 | |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
166 | for channel in client.channels: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
167 | if channel['logchannel']: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
168 | client.write ("PRIVMSG %s :%s" % (channel['name'], line)) |
0 | 169 | |
170 | # | |
171 | # Exception handling | |
172 | # | |
173 | def handle_exception(excType, excValue, trace): | |
174 | excepterm (traceback.format_exception(excType, excValue, trace)) | |
175 | ||
176 | def excepterm(data): | |
177 | for segment in data: | |
178 | for line in segment.splitlines(): | |
179 | print line | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
180 | chanlog (line) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
181 | |
0 | 182 | for client in g_clients: |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
183 | if len(data) > 0: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
184 | client.exceptdie() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
185 | else: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
186 | client.quit_irc() |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
187 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
188 | if g_BotActive: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
189 | restart_self() |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
190 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
191 | quit() |
0 | 192 | |
193 | sys.excepthook = handle_exception | |
194 | ||
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
195 | def check_admin (sender, ident, host, command): |
16
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
196 | if not "%s@%s" % (ident, host) in g_admins: |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
197 | raise logical_exception (".%s requires admin access" % command) |
0 | 198 | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
199 | class logical_exception (Exception): |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
200 | def __init__ (self, value): |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
201 | self.value = value |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
202 | def __str__ (self): |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
203 | return self.value |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
204 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
205 | # from http://www.daniweb.com/software-development/python/code/260268/restart-your-python-program |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
206 | def restart_self(): |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
207 | python = sys.executable |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
208 | os.execl (python, python, * sys.argv) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
209 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
210 | ' Check if a repository exists ' |
48
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
211 | def check_repo_exists (repo_name, repo_owner): |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
212 | print 'Checking that %s exists...' % repo_name |
48
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
213 | repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
214 | zanrepo = hgapi.Repo (repo_name) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
215 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
216 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
217 | zanrepo.hg_command ('id', '.') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
218 | except hgapi.hgapi.HgException: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
219 | # If the repo does not exist, clone it. After cloning, there obviously |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
220 | # are no more updates, so we'll be done. |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
221 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
222 | print 'Cloning %s...' % repo_name |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
223 | zanrepo.hg_clone (repo_url, repo_name) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
224 | print 'Cloning done. No update checking needed.' |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
225 | except Exception as e: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
226 | print 'Unable to clone %s from %s: %s' % (repo_name, repo_url, str (`e`)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
227 | quit(1) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
228 | #tried |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
229 | #enddef |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
230 | |
48
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
231 | check_repo_exists ('zandronum', 'Torr_Samaho') |
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
232 | check_repo_exists ('zandronum-stable', 'Torr_Samaho') |
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
233 | check_repo_exists ('zandronum-sandbox', 'crimsondusk') |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
234 | check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
235 | |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
236 | repocheck_timeout = {'zandronum':(time.time()) + 15, 'zandronum-stable':(time.time() + 15), 'zandronum-sandbox':(time.time()) + 15, 'zandronum-sandbox-stable':(time.time()) + 15} |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
237 | |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
238 | def get_commit_data (zanrepo, rev, template): |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
239 | return zanrepo.hg_command ('log', '-l', '1', '-r', rev, '--template', template) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
240 | #enddef |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
241 | |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
242 | def decipher_hgapi_error (e): |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
243 | # Blah, hgapi, why must your error messages be so mangled? |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
244 | try: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
245 | rawmsg = e.message.replace('\n', '').replace('" +','').replace('\t','') |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
246 | errmsg = re.compile (r'.*: tErr: (.*)Out:.*').match (rawmsg).group (1) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
247 | return [True, errmsg] |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
248 | except: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
249 | return [False, ''] |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
250 | #endtry |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
251 | #enddef |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
252 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
253 | def bbcodify(commit_diffstat): |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
254 | result='' |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
255 | for line in commit_diffstat.split('\n'): |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
256 | # Add green color-tags for the ++++++++++ stream |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
257 | rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$') |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
258 | match = rex.match (line) |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
259 | if match: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
260 | line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \ |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
261 | % (match.group (1), match.group (2), match.group (3), match.group (4), match.group (5)) |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
262 | |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
263 | # Tracker doesn't seem to like empty color tags |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
264 | line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '') |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
265 | #else: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
266 | #rex = re.compile (r'^(.*) ([0-9]+) insertions\(\+\), ([0-9]+) deletions\(\-\)$') |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
267 | #match = rex.match (line) |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
268 | #if match: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
269 | #line = '%s [b][color=green]%s[/color][/b] insertions, [b][color=red]%s[/color][/b] deletions\n' \ |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
270 | #% (match.group (1), match.group (2), match.group (3)) |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
271 | |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
272 | result += line |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
273 | #done |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
274 | |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
275 | return result |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
276 | #enddef |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
277 | |
50 | 278 | def find_developer_by_email (commit_email): |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
279 | for developer, emails in g_config['developer_emails'].iteritems(): |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
280 | for email in emails: |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
281 | if commit_email == email: |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
282 | return developer |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
283 | #fi |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
284 | #done |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
285 | #done |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
286 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
287 | return '' |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
288 | #enddef |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
289 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
290 | ' Retrieves and processes commits for zandronum repositories ' |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
291 | ' Ensure both repositories are OK before using this! ' |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
292 | def process_zan_repo_updates (repo_name): |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
293 | global repocheck_timeout |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
294 | global suds_client |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
295 | global g_config |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
296 | global g_clients |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
297 | |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
298 | usestable = repo_name == 'zandronum-stable' |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
299 | usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
300 | repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
301 | repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
302 | num_commits = 0 |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
303 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
304 | if time.time() < repocheck_timeout[repo_name]: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
305 | return |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
306 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
307 | repocheck_timeout[repo_name] = time.time() + (cfg ('hg_checkinterval', 15) * 60) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
308 | zanrepo = hgapi.Repo (repo_name) |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
309 | commit_data = [] |
42
adbf42ede463
- use a specific delimeter string '@@@@@@@@@@@' for hg incoming data as some commit messages are multi-line
Teemu Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
310 | delimeter = '@@@@@@@@@@' |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
311 | |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
312 | try: |
42
adbf42ede463
- use a specific delimeter string '@@@@@@@@@@@' for hg incoming data as some commit messages are multi-line
Teemu Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
313 | data = zanrepo.hg_command ('incoming', '--quiet', '--template', |
adbf42ede463
- use a specific delimeter string '@@@@@@@@@@@' for hg incoming data as some commit messages are multi-line
Teemu Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
314 | '{node|short} {desc}' + delimeter) |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
315 | except hgapi.hgapi.HgException as e: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
316 | deciphered = decipher_hgapi_error (e) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
317 | |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
318 | if deciphered[0] and len(deciphered[1]) > 0: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
319 | chanlog ("error while using hg import on %s: %s" % (repo_name, deciphered[1])) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
320 | #fi |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
321 | |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
322 | return |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
323 | except Exception as e: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
324 | chanlog ("%s" % `e`) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
325 | return |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
326 | #tried |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
327 | |
42
adbf42ede463
- use a specific delimeter string '@@@@@@@@@@@' for hg incoming data as some commit messages are multi-line
Teemu Piippo <crimsondusk64@gmail.com>
parents:
41
diff
changeset
|
328 | for line in data.split (delimeter): |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
329 | if line == '': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
330 | continue |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
331 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
332 | |
43
637cee1d89f0
- removed line delimeters from hg incoming regex parser
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
333 | rex = re.compile (r'([^ ]+) (.+)') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
334 | match = rex.match (line) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
335 | failed = False |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
336 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
337 | if not match: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
338 | chanlog ('malformed hg data: %s' % line) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
339 | continue |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
340 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
341 | |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
342 | commit_node = match.group (1) |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
343 | commit_message = match.group (2) |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
344 | commit_data.append ([commit_node, commit_message]) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
345 | #done |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
346 | |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
347 | if len (commit_data) > 0: |
53 | 348 | pull_args = []; |
349 | ||
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
350 | for commit in commit_data: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
351 | pull_args.append ('-r'); |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
352 | pull_args.append (commit[0]); |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
353 | #done |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
354 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
355 | try: |
52 | 356 | zanrepo.hg_command ('pull', *pull_args) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
357 | |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
358 | # Also pull these commits to the zandronum main repository |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
359 | if usestable: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
360 | devrepo = hgapi.Repo ('zandronum') |
52 | 361 | devrepo.hg_command ('pull', '../zandronum-stable', *pull_args) |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
362 | #fi |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
363 | |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
364 | # Pull everything into sandboxes too |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
365 | if not usesandbox: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
366 | devrepo = hgapi.Repo ('zandronum-sandbox') |
52 | 367 | devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
368 | |
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
369 | devrepo = hgapi.Repo ('zandronum-sandbox-stable') |
52 | 370 | devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
371 | #fi |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
372 | except Exception as e: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
373 | chanlog ('Warning: unable to pull: %s' % `e`) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
374 | return |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
375 | #tried |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
376 | #fi |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
377 | |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
378 | for commit in commit_data: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
379 | commit_node = commit[0] |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
380 | commit_message = commit[1] |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
381 | |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
382 | try: |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
383 | if usesandbox: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
384 | commit_author = get_commit_data (zanrepo, commit_node, '{author}') |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
385 | commit_url = '%s/commits/%s' % (repo_url, commit_node) |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
386 | commit_email = '' |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
387 | |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
388 | # Remove the email address from the author if possible |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
389 | rex = re.compile (r'^(.+) <([^>]+)>$.*') |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
390 | match = rex.match (commit_author) |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
391 | if match: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
392 | commit_author = match.group (1) |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
393 | commit_email = match.group (2) |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
394 | #fi |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
395 | |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
396 | commit_trackeruser = find_developer_by_email (commit_email) |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
397 | committer = commit_trackeruser if commit_trackeruser != '' else commit_author |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
398 | |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
399 | for irc_client in g_clients: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
400 | for channel in irc_client.cfg['channels']: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
401 | if 'btprivate' in channel and channel['btprivate'] == True: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
402 | irc_client.privmsg (channel['name'], |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
403 | "%s: new commit %s by %s: %s" |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
404 | % (repo_name, commit_node, committer, commit_url)) |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
405 | |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
406 | for line in commit_message.split ('\n'): |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
407 | irc_client.privmsg (channel['name'], line) |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
408 | #fi |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
409 | #done |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
410 | #done |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
411 | |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
412 | num_commits += 1 |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
413 | continue |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
414 | #fi |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
415 | |
54
180ae24d46f2
- also check for 'should fix' in commit messages
Teemu Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
416 | rex = re.compile (r'^.*(fixes|resolves|addresses|should fix) ([0-9]+).*$') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
417 | match = rex.match (commit_message) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
418 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
419 | if not match: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
420 | continue # no "fixes" message in the commit |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
421 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
422 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
423 | ticket_id = int (match.group (2)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
424 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
425 | # Acquire additional data |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
426 | moredata = get_commit_data (zanrepo, commit_node, |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
427 | '{author|nonempty}\n{date(date, \'%A %d %B %Y %T\')}').split('\n') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
428 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
429 | if len (moredata) != 2: |
40
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
430 | chanlog ('error while processing %s: malformed hg data' % commit_node) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
431 | continue |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
432 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
433 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
434 | commit_author = moredata[0] |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
435 | commit_date = moredata[1] |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
436 | commit_email = "" |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
437 | |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
438 | try: |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
439 | ticket_data = suds_client.service.mc_issue_get (g_config['trackeruser'], |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
440 | g_config['trackerpassword'], ticket_id) |
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
441 | except Exception as e: |
40
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
442 | chanlog ('error while processing %s: %s' % (commit_node, `e`)) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
443 | continue |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
444 | #tried |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
445 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
446 | # Remove the email address from the author if possible |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
447 | rex = re.compile (r'^(.+) <([^>]+)>$.*') |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
448 | match = rex.match (commit_author) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
449 | if match: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
450 | commit_author = match.group (1) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
451 | commit_email = match.group (2) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
452 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
453 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
454 | commit_diffstat = zanrepo.hg_command ('diff', '--change', commit_node, '--stat') |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
455 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
456 | if len(commit_diffstat) > 0: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
457 | # commit_diffstat = 'Changes in files:\n[code]\n' + commit_diffstat + '\n[/code]' |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
458 | commit_diffstat = 'Changes in files:\n' + bbcodify(commit_diffstat) |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
459 | else: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
460 | commit_diffstat = 'No changes in files.' |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
461 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
462 | # Compare the email addresses against known developer usernames |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
463 | commit_trackeruser = find_developer_by_email (commit_email) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
464 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
465 | if commit_trackeruser != '': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
466 | commit_author += ' [%s]' % commit_trackeruser |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
467 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
468 | |
37
3399d716b3ae
- fixed: the [url] tags in BT messages had unnecessary quotes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
469 | message = 'Issue addressed by commit %s: [b][url=%s/commits/%s]%s[/url][/b]' \ |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
470 | % (commit_node, repo_url, commit_node, commit_message) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
471 | message += "\nCommitted by %s on %s\n\n%s" \ |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
472 | % (commit_author, commit_date, commit_diffstat) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
473 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
474 | need_update = False |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
475 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
476 | # If not already set, set handler |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
477 | if not 'handler' in ticket_data: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
478 | ticket_data['handler'] = {'name': commit_trackeruser} |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
479 | need_update = True |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
480 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
481 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
482 | # Find out the status level of the ticket |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
483 | needs_testing_level = 70 |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
484 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
485 | if ticket_data['status']['id'] < needs_testing_level: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
486 | ticket_data.status['id'] = needs_testing_level |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
487 | need_update = True |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
488 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
489 | |
35
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
490 | # Set target version if not set |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
491 | if not 'target_version' in ticket_data: |
45
fdfcdf405b16
- bump interpreted version number of zandronum-stable from 1.3 to 1.4
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
492 | ticket_data['target_version'] = '1.4' if repo_name == 'zandronum-stable' else '2.0' |
35
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
493 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
494 | elif (ticket_data['target_version'] == '2.0' or ticket_data['target_version'] == '2.0-beta') \ |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
495 | and repo_name == 'zandronum-stable': |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
496 | # Target version was 2.0 but this was just committed to zandronum-stable, adjust |
45
fdfcdf405b16
- bump interpreted version number of zandronum-stable from 1.3 to 1.4
Teemu Piippo <crimsondusk64@gmail.com>
parents:
44
diff
changeset
|
497 | ticket_data['target_version'] = '1.4' |
35
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
498 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
499 | elif ticket_data['target_version'] == '2.0-beta': |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
500 | # Fix target version from 2.0-beta to 2.0 |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
501 | ticket_data['target_version'] = '2.0' |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
502 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
503 | #fi |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
504 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
505 | # Announce on IRC |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
506 | for irc_client in g_clients: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
507 | for channel in irc_client.cfg['channels']: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
508 | if 'btannounce' in channel and channel['btannounce'] == True: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
509 | irc_client.privmsg (channel['name'], |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
510 | "%s: commit %s fixes issue %d: %s" |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
511 | % (repo_name, commit_node, ticket_id, commit_message)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
512 | irc_client.privmsg (channel['name'], |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
513 | "Read all about it here: " + irc_client.get_ticket_url (ticket_id)) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
514 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
515 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
516 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
517 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
518 | if need_update: |
36
543d7a5e3b8b
- when updating BT tickets, the note data must be cleared in order to not update all the tickets in the ticket. WTF is MantisBT smoking?
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
519 | # We need to remove the note data, otherwise the ticket notes |
543d7a5e3b8b
- when updating BT tickets, the note data must be cleared in order to not update all the tickets in the ticket. WTF is MantisBT smoking?
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
520 | # will get unnecessary updates. WTF, MantisBT? |
543d7a5e3b8b
- when updating BT tickets, the note data must be cleared in order to not update all the tickets in the ticket. WTF is MantisBT smoking?
Teemu Piippo <crimsondusk64@gmail.com>
parents:
35
diff
changeset
|
521 | ticket_data.notes = [] |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
522 | suds_client.service.mc_issue_update (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, ticket_data) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
523 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
524 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
525 | suds_client.service.mc_issue_note_add (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, { 'text': message }) |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
526 | num_commits += 1 |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
527 | except Exception as e: |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
528 | chanlog ('Error while processing %s: %s' % (commit_node, `e`)) |
39
afd590258a93
- reworked repository watching. Now uses incoming only once to get a list of commits, then pulls, then operates on pulled data. The incoming command doesn't seem to support the '-r' switch properly? Should also be a bit faster now and should use less networking.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
38
diff
changeset
|
529 | continue |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
530 | #tried |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
531 | #done |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
532 | |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
533 | return num_commits > 0 |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
534 | #enddef |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
535 | |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
536 | def plural (a): |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
537 | return '' if a == 1 else 's' |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
538 | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
539 | # |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
540 | # Main IRC client class |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
541 | # |
0 | 542 | class irc_client (asyncore.dispatcher): |
543 | def __init__ (self, cfg, flags): | |
544 | self.name = cfg['name'] | |
545 | self.host = cfg['address'] | |
546 | self.port = cfg['port'] | |
547 | self.password = cfg['password'] if 'password' in cfg else '' | |
548 | self.channels = cfg['channels'] | |
549 | self.flags = flags | |
550 | self.send_buffer = list() | |
551 | self.umode = cfg['umode'] if 'umode' in cfg else '' | |
552 | self.cfg = cfg | |
553 | self.mynick = '' | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
554 | self.verbose = g_config['verbose'] if 'verbose' in g_config else False |
11
90851b22ab88
- gddmnt, python. you and your type system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
555 | self.commandprefix = g_config['commandprefix'][0] if 'commandprefix' in g_config else '.' |
8
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
556 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
557 | for channel in self.channels: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
558 | if not 'logchannel' in channel: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
559 | channel['logchannel'] = False |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
560 | channel['namesdone'] = True |
27
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
561 | #channel['haslinkbot'] = False |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
562 | |
8
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
563 | if not 'conflictsuffix' in self.cfg: |
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
564 | self.cfg['conflictsuffix'] = '`' |
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
565 | |
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
566 | self.desired_name = self.cfg['nickname'] if 'nickname' in self.cfg else g_config['nickname'] |
0 | 567 | g_clients.append (self) |
568 | asyncore.dispatcher.__init__ (self) | |
569 | self.create_socket (socket.AF_INET, socket.SOCK_STREAM) | |
570 | self.connect ((self.host, self.port)) | |
571 | ||
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
572 | def register_to_irc (self): |
0 | 573 | ident = self.cfg['ident'] if 'ident' in self.cfg else g_config['ident'] |
574 | gecos = self.cfg['gecos'] if 'gecos' in self.cfg else g_config['gecos'] | |
575 | if 'password' in self.cfg: | |
576 | self.write ("PASS %s" % self.cfg['password']) | |
577 | self.write ("USER %s * * :%s" % (ident, gecos)) | |
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
578 | self.write ("NICK %s" % self.mynick) |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
579 | |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
580 | def handle_connect (self): |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
581 | self.mynick = self.desired_name |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
582 | print "Connected to [%s] %s:%d" % (self.name, self.host, self.port) |
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
583 | self.register_to_irc() |
0 | 584 | |
17
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
585 | def write (self, utfdata): |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
586 | try: |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
587 | self.send_buffer.append ("%s" % utfdata.decode("utf-8","ignore").encode("ascii","ignore")) |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
588 | except UnicodeEncodeError: |
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
589 | pass |
0 | 590 | |
591 | def handle_close (self): | |
592 | print "Connection to [%s] %s:%d terminated." % (self.name, self.host, self.port) | |
593 | self.close() | |
594 | ||
595 | def handle_write (self): | |
596 | self.send_all_now() | |
597 | ||
598 | def readable (self): | |
599 | return True | |
600 | ||
601 | def writable (self): | |
602 | return len (self.send_buffer) > 0 | |
603 | ||
604 | def send_all_now (self): | |
605 | for line in self.send_buffer: | |
9
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
606 | if self.verbose: |
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
607 | print "[%s] <- %s" % (self.name, line) |
0 | 608 | self.send ("%s\n" % line) |
609 | self.send_buffer = [] | |
610 | ||
611 | def handle_read (self): | |
612 | lines = self.recv (4096).splitlines() | |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
613 | for utfline in lines: |
16
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
614 | try: |
17
f604687dd35b
- don't try to send stuff we cannot convert to ascii.. I don't like it but it's better than a crash
Santeri Piippo <crimsondusk64@gmail.com>
parents:
16
diff
changeset
|
615 | line = utfline.decode("utf-8","ignore").encode("ascii","ignore") |
16
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
616 | except UnicodeDecodeError: |
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
617 | continue |
6672cecf3ed1
- don't crash if unicode parsing fails, don't require nickname for admin masks
Santeri Piippo <crimsondusk64@gmail.com>
parents:
15
diff
changeset
|
618 | |
9
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
619 | if self.verbose: |
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
620 | print "[%s] -> %s" % (self.name, line) |
0 | 621 | |
622 | if line.startswith ("PING :"): | |
623 | self.write ("PONG :%s" % line[6:]) | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
624 | else: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
625 | words = line.split(" ") |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
626 | if len(words) >= 2: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
627 | if words[1] == "001": |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
628 | self.flags |= CLIF_CONNECTED |
0 | 629 | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
630 | for channel in self.cfg['channels']: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
631 | self.write ("JOIN %s %s" % (channel['name'], channel['password'] if 'password' in channel else '')) |
0 | 632 | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
633 | if 'umode' in self.cfg: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
634 | self.write ('MODE %s %s' % (self.mynick, self.cfg['umode'])) |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
635 | elif words[1] == "PRIVMSG": |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
636 | self.handle_privmsg (line) |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
637 | elif words[1] == 'JOIN': |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
638 | rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) JOIN :#(.+)') |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
639 | match = rex.match (line) |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
640 | |
27
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
641 | #if match and match.group(1).toLower() == 'linkbot': |
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
642 | #channel_by_name (match.group(4))['haslinkbot'] = True |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
643 | elif words[1] == 'QUIT': |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
644 | rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) QUIT') |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
645 | match = rex.match (line) |
0 | 646 | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
647 | # Try reclaim our nickname if possible |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
648 | if match and match.group(1) == self.desired_name: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
649 | self.mynick = self.desired_name |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
650 | self.write ("NICK %s" % self.mynick) |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
651 | |
27
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
652 | #if match and match.group(1).toLower() == 'linkbot': |
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
653 | #for channel in self.channels: |
ac59b5ae7a78
- disabled unstable/incomplete linkbot code.. I need to learn to stash changes proper
Teemu Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
654 | #channels['haslinkbot'] = False |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
655 | elif words[1] == "433": |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
656 | #:irc.localhost 433 * cobalt :Nickname is already in use. |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
657 | self.mynick = '%s%s' % (self.mynick, self.cfg['conflictsuffix']) |
7
438dc247ceb9
- handle nickname shenanigans: handle 433 message and try reclaim nickname if someone who has taken it (possibly our own ghost) disconnected
Santeri Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
658 | self.write ("NICK %s" % self.mynick) |
0 | 659 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
660 | # Check for new issues on the bugtracker |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
661 | bt_checklatest() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
662 | |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
663 | # Check for new commits in the repositories |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
664 | for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable']: |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
665 | process_zan_repo_updates (n) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
666 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
667 | def channel_by_name (self, name): |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
668 | for channel in self.channels: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
669 | if channel['name'].upper() == args[0].upper(): |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
670 | return channel |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
671 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
672 | raise logical_exception ('unknown channel ' + args[0]) |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
673 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
674 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
675 | # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
676 | # Handle a PRIVMSG line from the IRC server |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
677 | # |
0 | 678 | def handle_privmsg (self, line): |
679 | rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) PRIVMSG ([^ ]+) :(.+)$') | |
680 | match = rex.match (line) | |
681 | if match: | |
682 | sender = match.group (1) | |
683 | user = match.group (2) | |
684 | host = match.group (3) | |
685 | channel = match.group (4) | |
686 | message = match.group (5) | |
687 | replyto = channel if channel != g_mynick else sender | |
688 | ||
689 | # Check for tracker url in the message | |
690 | http_regex = re.compile (r'.*http(s?)://%s/view\.php\?id=([0-9]+).*' % g_config['trackerurl']) | |
691 | http_match = http_regex.match (line) | |
692 | ||
693 | # Check for command. | |
10
1b726db7b0ec
- respect the commandprefix option
Santeri Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
694 | if len(message) >= 2 and message[0] == self.commandprefix and message[1] != self.commandprefix: |
0 | 695 | stuff = message[1:].split(' ') |
696 | command = stuff[0] | |
697 | args = stuff[1:] | |
698 | try: | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
699 | self.handle_command (sender, user, host, replyto, command, args) |
21
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
700 | except logical_exception as e: |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
701 | for line in e.value.split ('\n'): |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
702 | if len(line) > 0: |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
703 | self.privmsg (replyto, "error: %s" % line) |
0 | 704 | elif http_match: |
705 | self.get_ticket_data (replyto, http_match.group (2), False) | |
706 | else: | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
707 | chanlog ("Recieved bad PRIVMSG: %s" % line) |
0 | 708 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
709 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
710 | # |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
711 | # Get the URL for a specified ticket |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
712 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
713 | def get_ticket_url (self, ticket): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
714 | return 'https://%s/view.php?id=%s' % (g_config['trackerurl'], ticket) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
715 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
716 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
717 | # |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
718 | # Retrieve a ticket from mantisbt |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
719 | # |
0 | 720 | def get_ticket_data (self, replyto, ticket, withlink): |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
721 | if suds_active == False: |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
722 | return |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
723 | |
0 | 724 | data = {} |
725 | try: | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
726 | data = bt_getissue (ticket) |
0 | 727 | except Exception, e: |
728 | self.privmsg (replyto, "Failed to get info for issue %s: %s" % (ticket, `e`)) | |
729 | ||
730 | if data: | |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
731 | if data['view_state']['name'] == 'private': |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
732 | allowprivate = False |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
733 | |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
734 | for channel in self.channels: |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
735 | if channel['name'] == replyto and 'btprivate' in channel and channel['btprivate'] == True: |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
736 | allowprivate = True |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
737 | break |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
738 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
739 | #done |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
740 | |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
741 | if not allowprivate: |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
742 | self.privmsg (replyto, 'Error: ticket %s is private' % ticket) |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
743 | return |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
744 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
745 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
746 | |
0 | 747 | self.privmsg (replyto, "Issue %s: %s: Reporter: %s, assigned to: %s, status: %s (%s)" % \ |
748 | (ticket, \ | |
749 | data.summary, \ | |
4
bd9508f8a10f
- don't crash if ticket data doesn't have a reporter name (can happen if the reporter is banned)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
3
diff
changeset
|
750 | data.reporter.name if hasattr (data.reporter, 'name') else "<unknown>", \ |
0 | 751 | data.handler.name if hasattr (data, 'handler') else "nobody", \ |
752 | data.status.name, \ | |
753 | data.resolution.name)) | |
754 | ||
755 | if withlink: | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
756 | self.privmsg (replyto, "Read all about it here: " + self.get_ticket_url (ticket)) |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
757 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
758 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
759 | #enddef |
0 | 760 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
761 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
762 | # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
763 | # Process an IRC command |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
764 | # |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
765 | def handle_command (self, sender, ident, host, replyto, command, args): |
0 | 766 | if command == "raw": |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
767 | check_admin (sender, ident, host, command) |
0 | 768 | self.write (" ".join (args)) |
769 | elif command == "msg": | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
770 | check_admin (sender, ident, host, command) |
0 | 771 | if len(args) < 2: |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
772 | raise logical_exception ("usage: .%s <target> <message...>" % command) |
0 | 773 | self.privmsg (args[0], " ".join (args[1:])) |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
774 | elif command == 'ticket': |
0 | 775 | if len(args) != 1: |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
776 | raise logical_exception ("usage: .%s <ticket>" % command) |
0 | 777 | self.get_ticket_data (replyto, args[0], True) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
778 | elif command == 'testannounce': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
779 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
780 | if len(args) != 1: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
781 | raise logical_exception ("usage: .%s <ticket>" % command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
782 | self.announce_ticket (bt_getissue (args[0])) |
21
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
783 | elif command == 'multierror': |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
784 | raise logical_exception ('a\nb\nc\n') |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
785 | elif command == 'idgames': |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
786 | try: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
787 | if len(args) < 1: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
788 | raise logical_exception ('usage: .%s <keywords>' % command) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
789 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
790 | url = g_idgamesSearchURL % urllib.quote (" ".join (args[0:])) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
791 | response = urllib2.urlopen (url).read() |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
792 | data = json.loads (response) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
793 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
794 | if 'content' in data and 'file' in data['content']: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
795 | if type (data['content']['file']) is list: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
796 | files = data['content']['file'] |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
797 | else: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
798 | files = [data['content']['file']] |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
799 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
800 | i = 0 |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
801 | for filedata in files: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
802 | if i >= 5: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
803 | break |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
804 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
805 | self.privmsg (replyto, '- %s: \'%s\' by \'%s\', rating: %s: %s' % \ |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
806 | (filedata['filename'], filedata['title'], filedata['author'], filedata['rating'], filedata['url'])) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
807 | |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
808 | i += 1 |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
809 | self.privmsg (replyto, "(%d / %d results posted)" % (i, len(files))) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
810 | elif 'warning' in data and 'message' in data['warning']: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
811 | raise logical_exception (data['warning']['message']) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
812 | elif 'error' in data and 'message' in data['error']: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
813 | raise logical_exception (data['error']['message']) |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
814 | else: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
815 | raise logical_exception ("Incomplete JSON response from doomworld.com/idgames") |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
816 | except logical_exception as e: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
817 | raise e |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
818 | except Exception as e: |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
819 | raise logical_exception ('Search failed: %s' % `e`) |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
820 | elif command == 'restart': |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
821 | check_admin (sender, ident, host, command) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
822 | excepterm('') |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
823 | elif command == 'update': |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
824 | check_admin (sender, ident, host, command) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
825 | |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
826 | try: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
827 | repo = hgapi.Repo ('.') |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
828 | r1 = repo.hg_id() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
829 | repo.hg_pull() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
830 | repo.hg_update('tip', True) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
831 | r2 = repo.hg_id() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
832 | if r1 != r2: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
833 | self.privmsg (replyto, 'Updated to %s, restarting...' % r2) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
834 | excepterm('') |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
835 | else: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
836 | self.privmsg (replyto, 'Up to date at %s.' % r2) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
837 | except hgapi.HgException as e: |
21
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
838 | raise logical_exception ('Update failed: %s' % str (e)) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
839 | elif command == 'addchan': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
840 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
841 | if len(args) != 1: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
842 | raise logical_exception ("usage: .%s <channel>" % command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
843 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
844 | for channel in self.channels: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
845 | if channel['name'].upper() == args[0].upper(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
846 | raise logical_exception ('I already know of %s!' % args[0]) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
847 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
848 | chan = {} |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
849 | chan['name'] = args[0] |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
850 | chan['logchannel'] = False |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
851 | self.channels.append (chan) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
852 | self.write ('JOIN ' + chan['name']) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
853 | save_config() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
854 | elif command == 'delchan': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
855 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
856 | if len(args) != 1: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
857 | raise logical_exception ("usage: .%s <channel>" % command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
858 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
859 | for channel in self.channels: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
860 | if channel['name'].upper() == args[0].upper(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
861 | break; |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
862 | else: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
863 | raise logical_exception ('unknown channel ' + args[0]) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
864 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
865 | self.channels.remove (channel) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
866 | self.write ('PART ' + args[0]) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
867 | save_config() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
868 | elif command == 'chanattr': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
869 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
870 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
871 | if len(args) < 1: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
872 | raise logical_exception ("usage: .%s <attribute> [value...]" % command) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
873 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
874 | for channel in self.channels: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
875 | if channel['name'] == replyto: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
876 | break |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
877 | else: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
878 | raise logical_exception ('I don\'t know of a channel named ' + replyto) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
879 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
880 | key = args[0] |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
881 | |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
882 | if len(args) < 2: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
883 | try: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
884 | self.privmsg (replyto, '%s = %s' % (key, channel[key])) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
885 | except KeyError: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
886 | self.privmsg (replyto, 'attribute %s is not set' % key) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
887 | else: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
888 | value = " ".join (args[1:]) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
889 | if key == 'name': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
890 | if replyto == channel['name']: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
891 | replyto = value |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
892 | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
893 | self.write ('PART ' + channel['name']) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
894 | channel['name'] = value |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
895 | self.write ('JOIN ' + channel['name'] + ' ' + (channel['password'] if hasattr (channel, 'password') else '')) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
896 | elif key == 'password': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
897 | channel['password'] = value |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
898 | elif key == 'btannounce': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
899 | channel['btannounce'] = bool_from_string (value) |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
900 | elif key == 'btprivate': |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
901 | channel['btprivate'] = bool_from_string (value) |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
902 | elif key == 'logchannel': |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
903 | channel['logchannel'] = bool_from_string (value) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
904 | else: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
905 | raise logical_exception ('unknown key ' + key) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
906 | |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
907 | self.privmsg (replyto, '%s is now %s' % (key, channel[key])) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
908 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
909 | save_config() |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
910 | elif command == 'devemail': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
911 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
912 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
913 | if len(args) < 2: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
914 | raise logical_exception ("usage: .%s <user> <email>" % command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
915 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
916 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
917 | if not 'developer_emails' in g_config: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
918 | g_config['developer_emails'] = {} |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
919 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
920 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
921 | user = ' '.join (args[0:-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
922 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
923 | if args[0] in g_config['developer_emails']: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
924 | g_config['developer_emails'][user].append (args[-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
925 | else: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
926 | g_config['developer_emails'][user] = [args[-1]] |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
927 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
928 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
929 | self.privmsg (replyto, 'Developer emails for %s are now %s' % |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
930 | (user, ', '.join (g_config['developer_emails'][user]))) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
931 | save_config() |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
932 | elif command == 'deldevemail': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
933 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
934 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
935 | if len(args) < 2: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
936 | raise logical_exception ("usage: .%s <user> <email>" % command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
937 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
938 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
939 | if not 'developer_emails' in g_config: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
940 | g_config['developer_emails'] = {} |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
941 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
942 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
943 | user = ' '.join (args[0:-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
944 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
945 | if user in g_config['developer_emails']: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
946 | try: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
947 | g_config['developer_emails'][user].remove (args[-1]) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
948 | except: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
949 | pass |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
950 | #tried |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
951 | |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
952 | if len (g_config['developer_emails'][user]) == 0: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
953 | g_config['developer_emails'].pop (user) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
954 | self.privmsg (replyto, 'No more developer emails for %s' % user) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
955 | else: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
956 | self.privmsg (replyto, 'Developer emails for %s are now %s' % |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
957 | (user, ', '.join (g_config['developer_emails'][user]))) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
958 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
959 | save_config() |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
960 | else: |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
961 | self.privmsg (replyto, 'There is no developer \'%s\'' % user) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
962 | #fi |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
963 | elif command == 'listdevemails': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
964 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
965 | |
30
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
966 | if 'developer_emails' in g_config: |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
967 | for dev, emails in g_config['developer_emails'].iteritems(): |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
968 | self.privmsg (replyto, 'Emails for %s: %s' % (dev, ', '.join (emails))) |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
969 | #done |
31
4e3259daa425
- GOD. DAMNIT. PYTHON.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
970 | else: |
30
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
971 | self.privmsg (replyto, 'No dev emails.') |
114afc110afd
- fixed crash on listdevemails if there are no emails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
29
diff
changeset
|
972 | #fi |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
973 | elif command == 'checkhg': |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
974 | check_admin (sender, ident, host, command) |
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
975 | global repocheck_timeout |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
976 | repocheck_timeout = {'zandronum':0, 'zandronum-stable':0, 'zandronum-sandbox':0, 'zandronum-sandbox-stable':0} |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
977 | |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
978 | for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable']: |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
979 | numcommits = process_zan_repo_updates (n) |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
980 | |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
981 | if numcommits == 0: |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
982 | self.privmsg (replyto, 'No new commits in ' + n) |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
983 | #fi |
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
984 | #done |
6 | 985 | elif command == 'die': |
986 | check_admin (sender, ident, host, command) | |
987 | quit() | |
23
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
988 | elif command == 'convert': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
989 | if len(args) != 3 or args[1] != 'as': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
990 | raise logical_exception ("usage: .%s <value> as <valuetype>" % command) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
991 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
992 | value = float (args[0]) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
993 | valuetype = args[2] |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
994 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
995 | if valuetype in ['radians', 'degrees']: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
996 | if valuetype == 'radians': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
997 | radvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
998 | degvalue = (value * 180.) / math.pi |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
999 | else: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1000 | radvalue = (value * math.pi) / 180. |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1001 | degvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1002 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1003 | self.privmsg (replyto, '%s radians, %s degrees (%s)' %(radvalue, degvalue, degvalue % 360.)) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1004 | elif valuetype in ['celsius', 'fahrenheit']: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1005 | if valuetype == 'celsius': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1006 | celvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1007 | fahrvalue = value * 1.8 + 32 |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1008 | else: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1009 | celvalue = (value - 32) / 1.8 |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1010 | fahrvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1011 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1012 | self.privmsg (replyto, '%s degrees celsius, %s degrees fahrenheit' %(celvalue, fahrvalue)) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
1013 | else: |
24 | 1014 | raise logical_exception ('unknown valuetype, expected one of: degrees, radians (angle conversion), ' + |
1015 | 'celsius, fahrenheit (temperature conversion)') | |
28
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1016 | elif command == 'urban' or command == 'ud': |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1017 | try: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1018 | if len(args) < 1: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1019 | raise logical_exception ('usage: %s <word>' % command) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1020 | |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1021 | url = 'http://api.urbandictionary.com/v0/define?term=%s' % ('%20'.join (args)) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1022 | response = urllib2.urlopen (url).read() |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1023 | data = json.loads (response) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1024 | |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1025 | if 'list' in data and len(data['list']) > 0 and 'word' in data['list'][0] and 'definition' in data['list'][0]: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1026 | word = data['list'][0]['word'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1027 | definition = data['list'][0]['definition'].replace ('\r', ' ').replace ('\n', ' ').replace (' ', ' ') |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1028 | up = data['list'][0]['thumbs_up'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1029 | down = data['list'][0]['thumbs_down'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1030 | self.privmsg (replyto, "\002%s\002: %s\0033 %d\003 up,\0035 %d\003 down" % (word, definition, up, down)) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1031 | else: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1032 | self.privmsg (replyto, "couldn't find a definition of \002%s\002" % args[0]) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1033 | except logical_exception as e: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1034 | raise e |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1035 | except Exception as e: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
1036 | raise logical_exception ('Urban dictionary lookup failed: %s' % `e`) |
40
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1037 | elif command == 'hg': |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1038 | check_admin (sender, ident, host, command) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1039 | |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1040 | if len(args) < 2: |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1041 | raise logical_exception ('usage: %s <repo> <command...>' % command) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1042 | |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1043 | try: |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1044 | repo = hgapi.Repo (args[0]) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1045 | result = repo.hg_command (*args[1:]) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1046 | self.privmsg (replyto, result) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1047 | except hgapi.hgapi.HgException as e: |
41 | 1048 | result = decipher_hgapi_error (e) |
1049 | ||
1050 | if result[0]: | |
1051 | self.privmsg (replyto, 'error: %s' % result[1]) | |
1052 | else: | |
44
616743868d4a
- post the raw-form error if unable to decipher
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
1053 | self.privmsg (replyto, 'error: %s' % `e`) |
41 | 1054 | #fi |
40
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
1055 | #tried |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1056 | elif command == 'changeset' or command == 'cset' or command == 'rev': |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1057 | if len(args) != 1: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1058 | raise logical_exception ('usage: %s <changeset>' % command) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1059 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1060 | repo = None |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1061 | data = "" |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1062 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1063 | # The sandboxes contain all revisions in zandronum and zandronum-stable. |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1064 | # Thus we only need to try find the revision in the sandbox repos. |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1065 | for reponame in ['zandronum-sandbox', 'zandronum-sandbox-stable']: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1066 | try: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1067 | repo = hgapi.Repo (reponame) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1068 | repo.hg_command ("log", "-r", args[0], "--template", " ") |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1069 | break |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1070 | except hgapi.hgapi.HgException: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1071 | pass |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1072 | #done |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1073 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1074 | if repo == None: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1075 | self.privmsg (replyto, 'couldn\'t find changeset %s' % (args[0])) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1076 | else: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1077 | try: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1078 | data = repo.hg_command ("log", "-r", args[0], "--template", |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1079 | "{node|short}@@@@@@@{desc}@@@@@@@{author}@@@@@@@{diffstat}@@@@@@@{date(date, '%s')}") |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1080 | data = data.split ('@@@@@@@') |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1081 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1082 | node = data[0] |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1083 | message = data[1] |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1084 | author = data[2] |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1085 | diffstat = data[3] |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1086 | date = datetime.fromtimestamp (int (data[4])) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1087 | delta = datetime.now() - date |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1088 | datestring = '' |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1089 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1090 | # Remove the email address from the author if possible |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1091 | match = re.compile (r'^(.+) <([^>]+)>$.*').match (author) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1092 | if match: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1093 | author = match.group (1) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1094 | email = match.group (2) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1095 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1096 | username = find_developer_by_email (email) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1097 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1098 | if username != '': |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1099 | author = username |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1100 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1101 | if delta.days < 4: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1102 | if delta.days == 0: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1103 | if delta.seconds < 60: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1104 | datestring = 'just now' |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1105 | elif delta.seconds < 3600: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1106 | minutes = delta.seconds / 60 |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1107 | datestring = '%d minute%s ago' % (minutes, plural (minutes)) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1108 | else: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1109 | hours = delta.seconds / 3600 |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1110 | datestring = '%d hour%s ago' % (hours, plural (hours)) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1111 | else: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1112 | datestring = '%d day%s ago' % (delta.days, plural (delta.days)) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1113 | else: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1114 | datestring = 'on %s' % (str (date)) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1115 | #fi |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1116 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1117 | self.privmsg (replyto, 'changeset %s: committed by %s %s (%s)' % (node, author, datestring, diffstat)) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1118 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1119 | for line in message.split ('\n'): |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1120 | self.privmsg (replyto, ' ' + line) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1121 | except hgapi.hgapi.HgException as e: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1122 | result = decipher_hgapi_error (e) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1123 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1124 | if result[0]: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1125 | self.privmsg (replyto, 'error: %s' % result[1]) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1126 | else: |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1127 | self.privmsg (replyto, 'error: %s' % `e`) |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1128 | #tried |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1129 | #fi |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1130 | # else: |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
1131 | # raise logical_exception ("unknown command `.%s`" % command) |
0 | 1132 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1133 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1134 | # Print a ticket announce to appropriate channels |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1135 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1136 | def announce_ticket (self, data): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1137 | idstring = "%d" % data.id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1138 | while len(idstring) < 7: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1139 | idstring = "0" + idstring |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1140 | |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1141 | isprivate = data['view_state']['name'] == 'private' |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1142 | reporter = data['reporter']['name'] if hasattr (data['reporter'], 'name') else '<nobody>' |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1143 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1144 | for channel in self.cfg['channels']: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1145 | if 'btannounce' in channel and channel['btannounce'] == True: |
32
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1146 | if not isprivate or ('btprivate' in channel and channel['btprivate'] == True): |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1147 | self.write ("PRIVMSG %s :[%s] New issue %s, reported by %s: %s: %s" % \ |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1148 | (channel['name'], data['project']['name'], idstring, reporter, |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1149 | data['summary'], self.get_ticket_url (idstring))) |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1150 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1151 | #fi |
88899b43810b
- corrected repository handling on error: print errors with commit node and pull even when processing fails
Teemu Piippo <crimsondusk64@gmail.com>
parents:
31
diff
changeset
|
1152 | #done |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1153 | |
0 | 1154 | def handle_error(self): |
1155 | excepterm (traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) | |
1156 | ||
1157 | def privmsg (self, channel, msg): | |
1158 | self.write ("PRIVMSG %s :%s" % (channel, msg)) | |
1159 | ||
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1160 | def close_connection (self, message): |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1161 | if self.flags & CLIF_CONNECTED: |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1162 | self.write ("QUIT :" + message) |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1163 | self.send_all_now() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1164 | self.close() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1165 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1166 | def quit_irc (self): |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1167 | self.close_connection ('Leaving') |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1168 | |
0 | 1169 | def exceptdie (self): |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1170 | self.close_connection ('Caught exception') |
0 | 1171 | |
1172 | def keyboardinterrupt (self): | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1173 | self.close_connection ('KeyboardInterrupt') |
0 | 1174 | |
1
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
1175 | # |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
1176 | # Main procedure: |
29c7e9d13a30
- fixed up exception handling, no longer connects to every possible connection, rather uses the autoconnect config entry
Santeri Piippo <crimsondusk64@gmail.com>
parents:
0
diff
changeset
|
1177 | # |
0 | 1178 | try: |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1179 | for aconn in g_config['autoconnect']: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1180 | for conndata in g_config['connections']: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1181 | if conndata['name'] == aconn: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1182 | irc_client (conndata, 0) |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1183 | break |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1184 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1185 | raise logical_exception ("unknown autoconnect entry %s" % (aconn)) |
29
5767ee263b12
- now is able to track zandronum mercurial repositories and react to 'fixes 0001234' trigger messages in them
Teemu Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
1186 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1187 | g_BotActive = True |
0 | 1188 | asyncore.loop() |
1189 | except KeyboardInterrupt: | |
1190 | for client in g_clients: | |
1191 | client.keyboardinterrupt() | |
1192 | quit() |