Sun, 09 Nov 2014 20:01:06 +0200
- fixed bad channel config addressing
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 | |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
36 | import urllib |
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
37 | import urllib2 |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
38 | import hgapi |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
39 | import os |
15
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
40 | import suds |
23
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
41 | import math |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
42 | import json |
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 |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
44 | import modulecore as ModuleCore |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
45 | import configfile |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
46 | from configfile import Config |
62
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
47 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
48 | ModuleCore.init_data() |
0 | 49 | |
50 | try: | |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
51 | 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
|
52 | except: |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
53 | uid = -1 |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
54 | |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
55 | 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
|
56 | quit() |
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
57 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
58 | configfile.init() |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
59 | g_admins = Config.get_value ('admins', default=[]) |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
60 | g_mynick = Config.get_value ('nickname', default='cobalt') |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
61 | g_BotActive = False |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
62 | g_needCommitsTxtRebuild = True |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
63 | |
0 | 64 | # |
65 | # SOAP stuff | |
66 | # | |
3
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
67 | suds_active = False |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
68 | |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
69 | try: |
20
2603faf5f91b
- don't run as root without asking first, added more startup messages
Santeri Piippo <crimsondusk64@gmail.com>
parents:
19
diff
changeset
|
70 | print 'Initializing MantisBT connection...' |
15
e7999383db5a
- don't crash if utf parsing yields an UnicodeDecodeError
Santeri Piippo <crimsondusk64@gmail.com>
parents:
14
diff
changeset
|
71 | 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
|
72 | 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
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | pass |
0 | 77 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
78 | btannounce_active = False |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
79 | btannounce_timeout = 0 |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
80 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
81 | def bt_updatechecktimeout(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
82 | global btannounce_timeout |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
83 | btannounce_timeout = time.time() + (Config.get_node ('bt').get_value ('checkinterval', default=5) * 60) |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
84 | |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
85 | def bt_credentials(): |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
86 | bt = Config.get_node ('bt') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
87 | user = bt.get_value ('username', '') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
88 | password = bt.get_value ('password', '') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
89 | return [user, password] |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
90 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
91 | if suds_active: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
92 | sys.stdout.write ('Retrieving latest tracker ticket... ') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
93 | user, password = bt_credentials() |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
94 | btannounce_id = suds_client.service.mc_issue_get_biggest_id (user, password, 0) |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
95 | btannounce_active = True |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
96 | bt_updatechecktimeout() |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
97 | print btannounce_id |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
98 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
99 | def bt_getissue(ticket): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
100 | global suds_client |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
101 | user, password = bt_credentials() |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
102 | return suds_client.service.mc_issue_get (user, password, ticket) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
103 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
104 | def bt_checklatest(): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
105 | global btannounce_timeout |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
106 | global btannounce_id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
107 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
108 | if time.time() >= btannounce_timeout: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
109 | bt_updatechecktimeout() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
110 | newid = btannounce_id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
111 | try: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
112 | user, password = bt_credentials() |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
113 | newid = suds_client.service.mc_issue_get_biggest_id (user, password, 0) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
114 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
115 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
116 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
117 | while newid > btannounce_id: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
118 | try: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
119 | btannounce_id += 1 |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
120 | data = bt_getissue (btannounce_id) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
121 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
122 | for client in g_clients: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
123 | client.announce_ticket (data) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
124 | except Exception as e: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
125 | pass |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
126 | |
0 | 127 | # |
128 | # irc_client flags | |
129 | # | |
130 | CLIF_CONNECTED = (1 << 1) | |
131 | ||
132 | # | |
133 | # List of all clients | |
134 | # | |
135 | g_clients = [] | |
136 | ||
137 | class channel (object): | |
138 | name = "" | |
139 | password = "" | |
140 | ||
141 | def __init__ (self, name): | |
142 | self.name = name | |
143 | ||
144 | # | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
145 | # Prints a line to log channel(s) |
0 | 146 | # |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
147 | def chanlog (line): |
0 | 148 | for client in g_clients: |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
149 | if not client.flags & CLIF_CONNECTED: |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
150 | continue |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
151 | |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
152 | for channel in client.channels: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
153 | if channel.get_value ('logchannel', default=False): |
68
ecc161d4a6fa
- fixed bad channel config addressing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
154 | client.write ("PRIVMSG %s :%s" % (channel.get_value ('name'), line)) |
0 | 155 | |
156 | # | |
157 | # Exception handling | |
158 | # | |
159 | def handle_exception(excType, excValue, trace): | |
160 | excepterm (traceback.format_exception(excType, excValue, trace)) | |
161 | ||
162 | def excepterm(data): | |
163 | for segment in data: | |
164 | for line in segment.splitlines(): | |
165 | print line | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
166 | chanlog (line) |
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
167 | |
0 | 168 | for client in g_clients: |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
169 | if len(data) > 0: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
170 | client.exceptdie() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
171 | else: |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
172 | client.quit_irc() |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
173 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
174 | 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
|
175 | restart_self() |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
176 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
177 | quit() |
0 | 178 | |
179 | sys.excepthook = handle_exception | |
180 | ||
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
|
181 | 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
|
182 | 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
|
183 | raise logical_exception (".%s requires admin access" % command) |
0 | 184 | |
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
|
185 | 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
|
186 | 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
|
187 | 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
|
188 | 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
|
189 | 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
|
190 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
191 | # 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
|
192 | def restart_self(): |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
193 | python = sys.executable |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
194 | os.execl (python, python, * sys.argv) |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
195 | |
59
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
196 | def make_commits_txt(): |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
197 | global g_needCommitsTxtRebuild |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
198 | |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
199 | if g_needCommitsTxtRebuild == False: |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
200 | return |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
201 | |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
202 | print 'Building commits.txt...' |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
203 | # Update zandronum-everything |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
204 | repo = hgapi.Repo ('zandronum-everything') |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
205 | repo.hg_command ('pull', '../zandronum-sandbox') |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
206 | repo.hg_command ('pull', '../zandronum-sandbox-stable') |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
207 | |
63
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
208 | data = repo.hg_command ('log', '--template', '{node} {date|hgdate}\n') |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
209 | |
59
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
210 | f = open ('commits.txt', 'w') |
63
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
211 | |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
212 | for line in data.split ('\n'): |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
213 | if line == '': |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
214 | continue |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
215 | |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
216 | words = line.split (' ') |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
217 | timestamp = int (words[1]) |
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
218 | f.write ('%s %s\n' % (words[0], datetime.utcfromtimestamp (timestamp).strftime ('%y%m%d-%H%M'))) |
59
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
219 | f.close() |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
220 | g_needCommitsTxtRebuild = False |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
221 | #enddef |
6a7199a714a1
- make_commits_txt must be higher up..
Teemu Piippo <crimsondusk64@gmail.com>
parents:
58
diff
changeset
|
222 | |
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
|
223 | ' Check if a repository exists ' |
48
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
224 | 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
|
225 | print 'Checking that %s exists...' % repo_name |
48
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
226 | 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
|
227 | 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
|
228 | |
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 | 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
|
230 | 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
|
231 | except hgapi.hgapi.HgException: |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
232 | # If the repo does not exist, clone it. zandronum-everything can be spawned off other repos though |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
233 | if repo_name == 'zandronum-everything': |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
234 | if not os.path.exists (repo_name): |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
235 | os.makedirs (repo_name) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
236 | |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
237 | global g_needCommitsTxtRebuild |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
238 | g_needCommitsTxtRebuild = True |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
239 | print 'Init %s' % repo_name |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
240 | zanrepo.hg_command ('init') |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
241 | print 'Cloning zandronum-sandbox into %s' % repo_name |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
242 | zanrepo.hg_command ('pull', '../zandronum-sandbox') |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
243 | print 'Cloning zandronum-sandbox-stable into %s' % repo_name |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
244 | zanrepo.hg_command ('pull', '../zandronum-sandbox-stable') |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
245 | print 'Done' |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
246 | make_commits_txt() |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
247 | return |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
248 | #fi |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
249 | |
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
|
250 | 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
|
251 | 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
|
252 | zanrepo.hg_clone (repo_url, repo_name) |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
253 | print 'Cloning done.' |
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
|
254 | 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
|
255 | 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
|
256 | 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
|
257 | #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
|
258 | #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
|
259 | |
48
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
260 | check_repo_exists ('zandronum', 'Torr_Samaho') |
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
261 | check_repo_exists ('zandronum-stable', 'Torr_Samaho') |
dbef418cc1c8
- now clones sandbox correctly
Teemu Piippo <crimsondusk64@gmail.com>
parents:
47
diff
changeset
|
262 | check_repo_exists ('zandronum-sandbox', 'crimsondusk') |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
263 | check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk') |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
264 | check_repo_exists ('zandronum-everything', '') |
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
|
265 | |
66
74d8ca04ff01
- reworked repocheck timeout
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
266 | repocheck_timeout = (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
|
267 | |
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
|
268 | 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
|
269 | 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
|
270 | #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
|
271 | |
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
|
272 | 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
|
273 | # 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
|
274 | 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
|
275 | 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
|
276 | 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
|
277 | 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
|
278 | 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
|
279 | 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
|
280 | #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
|
281 | #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
|
282 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
283 | def bbcodify(commit_diffstat): |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
284 | result='' |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
285 | 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
|
286 | # 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
|
287 | rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$') |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
288 | match = rex.match (line) |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
289 | if match: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
290 | 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
|
291 | % (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
|
292 | |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
293 | # 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
|
294 | 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
|
295 | #else: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
296 | #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
|
297 | #match = rex.match (line) |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
298 | #if match: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
299 | #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
|
300 | #% (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
|
301 | |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
302 | result += line |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
303 | #done |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
304 | |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
305 | return result |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
306 | #enddef |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
307 | |
50 | 308 | def find_developer_by_email (commit_email): |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
309 | for developer, emails in Config.get_value ('developer_emails', default={}).iteritems(): |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
310 | for email in emails: |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
311 | if commit_email == email: |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
312 | return developer |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
313 | #fi |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
314 | #done |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
315 | #done |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
316 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
317 | return '' |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
318 | #enddef |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
319 | |
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
|
320 | ' 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
|
321 | ' Ensure both repositories are OK before using this! ' |
66
74d8ca04ff01
- reworked repocheck timeout
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
322 | def process_zan_repo_updates(): |
74d8ca04ff01
- reworked repocheck timeout
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
323 | for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable']: |
67 | 324 | process_one_repo (n) |
66
74d8ca04ff01
- reworked repocheck timeout
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
325 | |
74d8ca04ff01
- reworked repocheck timeout
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
326 | def process_one_repo (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
|
327 | 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
|
328 | 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
|
329 | global g_clients |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
330 | |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
331 | hgns = Config.get_node ('hg') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
332 | |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
333 | if not hgns.get_value ('track', default=True): |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
334 | return |
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
|
335 | |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
336 | usestable = repo_name == 'zandronum-stable' |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
337 | 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
|
338 | repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
339 | 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
|
340 | num_commits = 0 |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
341 | btuser, btpassword = bt_credentials() |
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
|
342 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
343 | if time.time() < repocheck_timeout: |
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
|
344 | 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
|
345 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
346 | repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60 |
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
|
347 | 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
|
348 | 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
|
349 | 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
|
350 | |
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 | 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
|
352 | 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
|
353 | '{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
|
354 | 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
|
355 | 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
|
356 | |
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
|
357 | 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
|
358 | 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
|
359 | #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
|
360 | |
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
|
361 | 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
|
362 | 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
|
363 | 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
|
364 | 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
|
365 | #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
|
366 | |
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
|
367 | 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
|
368 | 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
|
369 | 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
|
370 | #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
|
371 | |
43
637cee1d89f0
- removed line delimeters from hg incoming regex parser
Teemu Piippo <crimsondusk64@gmail.com>
parents:
42
diff
changeset
|
372 | 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
|
373 | 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
|
374 | 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
|
375 | |
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
|
376 | 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
|
377 | 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
|
378 | 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
|
379 | #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
|
380 | |
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
|
381 | 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
|
382 | 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
|
383 | 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
|
384 | #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
|
385 | |
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
|
386 | if len (commit_data) > 0: |
53 | 387 | pull_args = []; |
388 | ||
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
|
389 | 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
|
390 | 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
|
391 | 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
|
392 | #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
|
393 | |
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
|
394 | try: |
52 | 395 | 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
|
396 | |
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
|
397 | # 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
|
398 | 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
|
399 | devrepo = hgapi.Repo ('zandronum') |
52 | 400 | 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
|
401 | #fi |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
402 | |
51
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
403 | # Pull everything into sandboxes too |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
404 | if not usesandbox: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
405 | devrepo = hgapi.Repo ('zandronum-sandbox') |
52 | 406 | 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
|
407 | |
b0209b707fa2
- now also tracks sandbox-stable
Teemu Piippo <crimsondusk64@gmail.com>
parents:
50
diff
changeset
|
408 | devrepo = hgapi.Repo ('zandronum-sandbox-stable') |
52 | 409 | devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
410 | #fi |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
411 | |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
412 | devrepo = hgapi.Repo ('zandronum-everything') |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
413 | devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
414 | |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
415 | global g_needCommitsTxtRebuild |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
416 | g_needCommitsTxtRebuild = True |
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
|
417 | 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
|
418 | 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
|
419 | 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
|
420 | #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
|
421 | #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
|
422 | |
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
|
423 | 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
|
424 | 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
|
425 | 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
|
426 | |
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
|
427 | try: |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
428 | if usesandbox: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
429 | commit_author = get_commit_data (zanrepo, commit_node, '{author}') |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
430 | commit_url = '%s/commits/%s' % (repo_url, commit_node) |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
431 | commit_email = '' |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
432 | |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
433 | # Remove the email address from the author if possible |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
434 | rex = re.compile (r'^(.+) <([^>]+)>$.*') |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
435 | match = rex.match (commit_author) |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
436 | if match: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
437 | commit_author = match.group (1) |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
438 | commit_email = match.group (2) |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
439 | #fi |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
440 | |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
441 | commit_trackeruser = find_developer_by_email (commit_email) |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
442 | committer = commit_trackeruser if commit_trackeruser != '' else commit_author |
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
443 | |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
444 | for irc_client in g_clients: |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
445 | for channel in irc_client.cfg['channels']: |
68
ecc161d4a6fa
- fixed bad channel config addressing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
446 | if channel.get_value ('btprivate', False): |
ecc161d4a6fa
- fixed bad channel config addressing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
447 | irc_client.privmsg (channel.get_value ('name'), |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
448 | "%s: new commit %s by %s: %s" |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
449 | % (repo_name, commit_node, committer, commit_url)) |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
450 | |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
451 | for line in commit_message.split ('\n'): |
68
ecc161d4a6fa
- fixed bad channel config addressing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
452 | irc_client.privmsg (channel.get_value ('name'), line) |
47
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
453 | #fi |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
454 | #done |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
455 | #done |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
456 | |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
457 | num_commits += 1 |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
458 | continue |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
459 | #fi |
103f184951bb
- added sandbox support
Teemu Piippo <crimsondusk64@gmail.com>
parents:
46
diff
changeset
|
460 | |
54
180ae24d46f2
- also check for 'should fix' in commit messages
Teemu Piippo <crimsondusk64@gmail.com>
parents:
53
diff
changeset
|
461 | 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
|
462 | 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
|
463 | |
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 | 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
|
465 | 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
|
466 | #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
|
467 | |
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 | 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
|
469 | |
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 | # 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
|
471 | 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
|
472 | '{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
|
473 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
474 | if len (moredata) != 2: |
40
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
475 | 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
|
476 | 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
|
477 | #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
|
478 | |
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 | 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
|
480 | 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
|
481 | 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
|
482 | |
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
|
483 | try: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
484 | ticket_data = suds_client.service.mc_issue_get (btuser, btpassword, ticket_id) |
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
|
485 | except Exception as e: |
40
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
486 | 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
|
487 | 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
|
488 | #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
|
489 | |
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
|
490 | # 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
|
491 | 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
|
492 | 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
|
493 | 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
|
494 | 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
|
495 | 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
|
496 | #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
|
497 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
498 | 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
|
499 | |
46
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
500 | if len(commit_diffstat) > 0: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
501 | # 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
|
502 | 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
|
503 | else: |
c4d231fdf1c0
- now with a more detailed diffstat, in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
45
diff
changeset
|
504 | 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
|
505 | |
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 | # Compare the email addresses against known developer usernames |
49
2df3d5b2f364
- print username when possible
Teemu Piippo <crimsondusk64@gmail.com>
parents:
48
diff
changeset
|
507 | 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
|
508 | |
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 | 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
|
510 | 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
|
511 | #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
|
512 | |
37
3399d716b3ae
- fixed: the [url] tags in BT messages had unnecessary quotes
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
513 | 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
|
514 | % (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
|
515 | 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
|
516 | % (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
|
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 | 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
|
519 | |
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
|
520 | # 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
|
521 | 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
|
522 | 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
|
523 | 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
|
524 | #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
|
525 | |
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
|
526 | # 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
|
527 | 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
|
528 | |
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
|
529 | 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
|
530 | 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
|
531 | 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
|
532 | #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
|
533 | |
35
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
534 | # 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
|
535 | 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
|
536 | 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
|
537 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
538 | 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
|
539 | 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
|
540 | # 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
|
541 | 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
|
542 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
543 | 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
|
544 | # 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
|
545 | 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
|
546 | need_update = True |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
547 | #fi |
237e82bcd02f
- update target version in tickets when acting upon commit data
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
548 | |
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
|
549 | # 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
|
550 | for irc_client in g_clients: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
551 | for channel in irc_client.channels: |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
552 | if channel.get_value ('btannounce', default=True): |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
553 | irc_client.privmsg (channel.get_value ('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
|
554 | "%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
|
555 | % (repo_name, commit_node, ticket_id, commit_message)) |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
556 | irc_client.privmsg (channel.get_value ('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
|
557 | "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
|
558 | #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
|
559 | #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
|
560 | #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
|
561 | |
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
|
562 | 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
|
563 | # 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
|
564 | # 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
|
565 | ticket_data.notes = [] |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
566 | suds_client.service.mc_issue_update (btuser, btpassword, ticket_id, ticket_data) |
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
|
567 | #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
|
568 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
569 | suds_client.service.mc_issue_note_add (btuser, btpassword, ticket_id, { 'text': message }) |
34
1a1ee9e8bda6
- be more verbose when .checkhg is used
Teemu Piippo <crimsondusk64@gmail.com>
parents:
33
diff
changeset
|
570 | 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
|
571 | 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
|
572 | 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
|
573 | 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
|
574 | #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
|
575 | #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
|
576 | #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
|
577 | |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
578 | 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
|
579 | 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
|
580 | |
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
|
581 | # |
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
|
582 | # 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
|
583 | # |
0 | 584 | class irc_client (asyncore.dispatcher): |
585 | def __init__ (self, cfg, flags): | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
586 | self.name = cfg.get_value ('name') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
587 | self.host = cfg.get_value ('address') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
588 | self.port = cfg.get_value ('port', default=6667) |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
589 | self.password = cfg.get_value ('password', default='') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
590 | self.channels = cfg.get_nodelist ('channels') |
0 | 591 | self.flags = flags |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
592 | self.send_buffer = [] |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
593 | self.umode = cfg.get_value ('umode', default='') |
0 | 594 | self.cfg = cfg |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
595 | self.desired_name = Config.get_value ('nickname', default='cobalt') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
596 | self.mynick = self.desired_name |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
597 | self.verbose = Config.get_value ('verbose', default=False) |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
598 | self.commandprefix = Config.get_value ('commandprefix', default='.') |
8
dd467db4b18e
- made conflictsuffix configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
7
diff
changeset
|
599 | |
0 | 600 | g_clients.append (self) |
601 | asyncore.dispatcher.__init__ (self) | |
602 | self.create_socket (socket.AF_INET, socket.SOCK_STREAM) | |
603 | self.connect ((self.host, self.port)) | |
604 | ||
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
|
605 | def register_to_irc (self): |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
606 | ident = Config.get_value ('ident', default='cobalt') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
607 | gecos = Config.get_value ('gecos', default='cobalt') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
608 | self.write ("PASS %s" % self.password) |
0 | 609 | 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
|
610 | 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
|
611 | |
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
|
612 | 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
|
613 | 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
|
614 | self.register_to_irc() |
0 | 615 | |
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
|
616 | 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
|
617 | 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
|
618 | 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
|
619 | 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
|
620 | pass |
0 | 621 | |
622 | def handle_close (self): | |
623 | print "Connection to [%s] %s:%d terminated." % (self.name, self.host, self.port) | |
624 | self.close() | |
625 | ||
626 | def handle_write (self): | |
627 | self.send_all_now() | |
628 | ||
629 | def readable (self): | |
630 | return True | |
631 | ||
632 | def writable (self): | |
633 | return len (self.send_buffer) > 0 | |
634 | ||
635 | def send_all_now (self): | |
636 | for line in self.send_buffer: | |
9
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
637 | if self.verbose: |
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
638 | print "[%s] <- %s" % (self.name, line) |
0 | 639 | self.send ("%s\n" % line) |
640 | self.send_buffer = [] | |
641 | ||
642 | def handle_read (self): | |
643 | lines = self.recv (4096).splitlines() | |
2
1a24dd2d598e
- added a basic /idgames search
Santeri Piippo <crimsondusk64@gmail.com>
parents:
1
diff
changeset
|
644 | 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
|
645 | 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
|
646 | 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
|
647 | 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
|
648 | 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
|
649 | |
9
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
650 | if self.verbose: |
0604f6b9f781
- added verbosity setting
Santeri Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
651 | print "[%s] -> %s" % (self.name, line) |
0 | 652 | |
653 | if line.startswith ("PING :"): | |
654 | 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
|
655 | else: |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
656 | words = line.split(" ") |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
657 | 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
|
658 | 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
|
659 | self.flags |= CLIF_CONNECTED |
0 | 660 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
661 | for channel in self.channels: |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
662 | self.write ("JOIN %s %s" % (channel.get_value ('name'), channel.get_value ('password', default=''))) |
0 | 663 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
664 | umode = self.cfg.get_value ('umode', '') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
665 | |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
666 | if umode != '': |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
667 | self.write ('MODE %s %s' % (self.mynick, self.cfg.get_value ('umode', ''))) |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
668 | 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
|
669 | self.handle_privmsg (line) |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
670 | 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
|
671 | 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
|
672 | match = rex.match (line) |
0 | 673 | |
14
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
674 | # 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
|
675 | 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
|
676 | 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
|
677 | self.write ("NICK %s" % self.mynick) |
558379fd6d6a
- heartbeat the issue announcer even if we just get a ping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
13
diff
changeset
|
678 | 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
|
679 | #:irc.localhost 433 * cobalt :Nickname is already in use. |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
680 | self.mynick += self.cfg.get_value ('conflictsuffix', default='`') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
681 | self.write ("NICK " + self.mynick) |
0 | 682 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
683 | # Check for new issues on the bugtracker |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
684 | bt_checklatest() |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
685 | |
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
|
686 | # Check for new commits in the repositories |
66
74d8ca04ff01
- reworked repocheck timeout
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
687 | process_zan_repo_updates() |
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
|
688 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
689 | 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
|
690 | for channel in self.channels: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
691 | if channel.get_value ('name').upper() == args[0].upper(): |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
692 | return channel |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
693 | else: |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
694 | 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
|
695 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
696 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
697 | # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
698 | # Handle a PRIVMSG line from the IRC server |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
699 | # |
0 | 700 | def handle_privmsg (self, line): |
701 | rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) PRIVMSG ([^ ]+) :(.+)$') | |
702 | match = rex.match (line) | |
703 | if match: | |
704 | sender = match.group (1) | |
705 | user = match.group (2) | |
706 | host = match.group (3) | |
707 | channel = match.group (4) | |
708 | message = match.group (5) | |
709 | replyto = channel if channel != g_mynick else sender | |
710 | ||
711 | # Check for tracker url in the message | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
712 | url = Config.get_node ('bt').get_value ('url') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
713 | http_regex = re.compile (r'.*http(s?)://%s/view\.php\?id=([0-9]+).*' % url) |
0 | 714 | http_match = http_regex.match (line) |
715 | ||
716 | # Check for command. | |
10
1b726db7b0ec
- respect the commandprefix option
Santeri Piippo <crimsondusk64@gmail.com>
parents:
9
diff
changeset
|
717 | if len(message) >= 2 and message[0] == self.commandprefix and message[1] != self.commandprefix: |
0 | 718 | stuff = message[1:].split(' ') |
719 | command = stuff[0] | |
720 | args = stuff[1:] | |
721 | try: | |
62
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
722 | self.handle_command (sender, user, host, replyto, command, args, message) |
21
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
723 | except logical_exception as e: |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
724 | for line in e.value.split ('\n'): |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
725 | if len(line) > 0: |
8c389f46a056
- handle hg errors better
Santeri Piippo <crimsondusk64@gmail.com>
parents:
20
diff
changeset
|
726 | self.privmsg (replyto, "error: %s" % line) |
0 | 727 | elif http_match: |
728 | self.get_ticket_data (replyto, http_match.group (2), False) | |
729 | else: | |
19
ca618214fd07
- control connections turned into log channels
Santeri Piippo <crimsondusk64@gmail.com>
parents:
18
diff
changeset
|
730 | chanlog ("Recieved bad PRIVMSG: %s" % line) |
0 | 731 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
732 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
733 | # |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
734 | # Get the URL for a specified ticket |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
735 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
736 | def get_ticket_url (self, ticket): |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
737 | url = Config.get_node ('bt').get_value ('url') |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
738 | return 'https://%s/view.php?id=%s' % (url, ticket) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
739 | |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
740 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
741 | # |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
742 | # Retrieve a ticket from mantisbt |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
743 | # |
0 | 744 | 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
|
745 | if suds_active == False: |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
746 | return |
53486417a8e5
- handle the case where the mantisbt is not available
Santeri Piippo <crimsondusk64@gmail.com>
parents:
2
diff
changeset
|
747 | |
0 | 748 | data = {} |
749 | try: | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
750 | data = bt_getissue (ticket) |
0 | 751 | except Exception, e: |
752 | self.privmsg (replyto, "Failed to get info for issue %s: %s" % (ticket, `e`)) | |
753 | ||
754 | 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
|
755 | 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
|
756 | 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
|
757 | |
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 | for channel in self.channels: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
759 | if channel.get_value ('name') == replyto and channel.get_value ('btprivate', False): |
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
|
760 | 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
|
761 | 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
|
762 | #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
|
763 | #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
|
764 | |
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
|
765 | 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
|
766 | 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
|
767 | 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
|
768 | #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
|
769 | #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
|
770 | |
0 | 771 | self.privmsg (replyto, "Issue %s: %s: Reporter: %s, assigned to: %s, status: %s (%s)" % \ |
772 | (ticket, \ | |
773 | 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
|
774 | data.reporter.name if hasattr (data.reporter, 'name') else "<unknown>", \ |
0 | 775 | data.handler.name if hasattr (data, 'handler') else "nobody", \ |
776 | data.status.name, \ | |
777 | data.resolution.name)) | |
778 | ||
779 | if withlink: | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
780 | 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
|
781 | #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
|
782 | #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
|
783 | #enddef |
0 | 784 | |
62
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
785 | def is_admin (self, ident, host): |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
786 | return ("%s@%s" % (ident, host)) in g_admins |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
787 | |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
788 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
789 | # |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
790 | # Process an IRC command |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
791 | # |
62
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
792 | def handle_command (self, sender, ident, host, replyto, command, args, message): |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
793 | kvargs = {'sender': sender, 'ident': ident, 'host': host, 'replyto': replyto, 'cmdname': command, 'message': message} |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
794 | |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
795 | try: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
796 | result = ModuleCore.call_command (self, **kvargs) |
62
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
797 | |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
798 | if result: |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
799 | return |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
800 | except ModuleCore.CommandError as e: |
62
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
801 | lines = str (e).split ('\n') |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
802 | self.privmsg (replyto, 'error: %s' % lines[0]) |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
803 | |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
804 | for line in lines[1:]: |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
805 | self.privmsg (replyto, ' ' + line) |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
806 | return |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
807 | #tried |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
808 | |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
809 | if command == 'ticket': |
0 | 810 | 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
|
811 | raise logical_exception ("usage: .%s <ticket>" % command) |
0 | 812 | self.get_ticket_data (replyto, args[0], True) |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
813 | elif command == 'testannounce': |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
814 | check_admin (sender, ident, host, command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
815 | if len(args) != 1: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
816 | raise logical_exception ("usage: .%s <ticket>" % command) |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
817 | self.announce_ticket (bt_getissue (args[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
|
818 | 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
|
819 | 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
|
820 | global repocheck_timeout |
66
74d8ca04ff01
- reworked repocheck timeout
Teemu Piippo <crimsondusk64@gmail.com>
parents:
65
diff
changeset
|
821 | repocheck_timeout = 0 |
67 | 822 | process_zan_repo_updates() |
6 | 823 | elif command == 'die': |
824 | check_admin (sender, ident, host, command) | |
825 | quit() | |
23
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
826 | elif command == 'convert': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
827 | 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
|
828 | 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
|
829 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
830 | value = float (args[0]) |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
831 | valuetype = args[2] |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
832 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
833 | if valuetype in ['radians', 'degrees']: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
834 | if valuetype == 'radians': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
835 | radvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
836 | degvalue = (value * 180.) / math.pi |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
837 | else: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
838 | radvalue = (value * math.pi) / 180. |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
839 | degvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
840 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
841 | 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
|
842 | elif valuetype in ['celsius', 'fahrenheit']: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
843 | if valuetype == 'celsius': |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
844 | celvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
845 | fahrvalue = value * 1.8 + 32 |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
846 | else: |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
847 | celvalue = (value - 32) / 1.8 |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
848 | fahrvalue = value |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
849 | |
c25944cac3e6
- added .convert with angle and temperature conversions
Santeri Piippo <crimsondusk64@gmail.com>
parents:
21
diff
changeset
|
850 | 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
|
851 | else: |
24 | 852 | raise logical_exception ('unknown valuetype, expected one of: degrees, radians (angle conversion), ' + |
853 | 'celsius, fahrenheit (temperature conversion)') | |
28
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
854 | elif command == 'urban' or command == 'ud': |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
855 | try: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
856 | if len(args) < 1: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
857 | raise logical_exception ('usage: %s <word>' % command) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
858 | |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
859 | 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
|
860 | response = urllib2.urlopen (url).read() |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
861 | data = json.loads (response) |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
862 | |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
863 | 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
|
864 | word = data['list'][0]['word'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
865 | definition = data['list'][0]['definition'].replace ('\r', ' ').replace ('\n', ' ').replace (' ', ' ') |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
866 | up = data['list'][0]['thumbs_up'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
867 | down = data['list'][0]['thumbs_down'] |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
868 | 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
|
869 | else: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
870 | 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
|
871 | except logical_exception as e: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
872 | raise e |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
873 | except Exception as e: |
30257c78904f
- added urban dictionary lookup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
27
diff
changeset
|
874 | 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
|
875 | elif command == 'hg': |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
876 | check_admin (sender, ident, host, command) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
877 | |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
878 | if len(args) < 2: |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
879 | raise logical_exception ('usage: %s <repo> <command...>' % command) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
880 | |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
881 | try: |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
882 | repo = hgapi.Repo (args[0]) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
883 | result = repo.hg_command (*args[1:]) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
884 | self.privmsg (replyto, result) |
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
885 | except hgapi.hgapi.HgException as e: |
41 | 886 | result = decipher_hgapi_error (e) |
887 | ||
888 | if result[0]: | |
889 | self.privmsg (replyto, 'error: %s' % result[1]) | |
890 | else: | |
44
616743868d4a
- post the raw-form error if unable to decipher
Teemu Piippo <crimsondusk64@gmail.com>
parents:
43
diff
changeset
|
891 | self.privmsg (replyto, 'error: %s' % `e`) |
41 | 892 | #fi |
40
f6512aacb114
- fine tuning, added .hg command
Teemu Piippo <crimsondusk64@gmail.com>
parents:
39
diff
changeset
|
893 | #tried |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
894 | 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
|
895 | 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
|
896 | 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
|
897 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
898 | repo = hgapi.Repo ('zandronum-everything') |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
899 | data = "" |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
900 | node = args[0] |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
901 | |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
902 | # Possibly we're passed a date version instead. Try find the node for this. |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
903 | try: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
904 | datetime.strptime (args[0], '%y%m%d-%H%M') |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
905 | make_commits_txt() |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
906 | commits_txt = open ('commits.txt', 'r') |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
907 | |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
908 | for line in commits_txt: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
909 | data = line.replace ('\n', '').split (' ') |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
910 | if data[1] == args[0]: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
911 | node = data[0] |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
912 | break |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
913 | else: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
914 | self.privmsg (replyto, 'couldn\'t find changset for date %s' % args[0]) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
915 | return |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
916 | #done |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
917 | except ValueError: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
918 | pass |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
919 | #tried |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
920 | |
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
921 | # 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
|
922 | # Thus we only need to try find the revision in the sandbox repos. |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
923 | try: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
924 | repo.hg_command ("log", "-r", node, "--template", " ") |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
925 | except hgapi.hgapi.HgException: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
926 | self.privmsg (replyto, 'couldn\'t find changeset %s' % (node)) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
927 | return |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
928 | #tried |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
929 | |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
930 | try: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
931 | data = repo.hg_command ("log", "-r", node, "--template", |
63
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
932 | "{node|short}@@@@@@@{desc}@@@@@@@{author}@@@@@@@{diffstat}@@@@@@@{date|hgdate}") |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
933 | data = data.split ('@@@@@@@') |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
934 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
935 | node = data[0] |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
936 | message = data[1] |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
937 | author = data[2] |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
938 | diffstat = data[3] |
63
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
939 | date = datetime.utcfromtimestamp (int (data[4].split (' ')[0])) |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
940 | delta = datetime.now() - date |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
941 | datestring = '' |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
942 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
943 | # Remove the email address from the author if possible |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
944 | match = re.compile (r'^(.+) <([^>]+)>$.*').match (author) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
945 | if match: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
946 | author = match.group (1) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
947 | email = match.group (2) |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
948 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
949 | username = find_developer_by_email (email) |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
950 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
951 | if username != '': |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
952 | author = username |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
953 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
954 | if delta.days < 4: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
955 | if delta.days == 0: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
956 | if delta.seconds < 60: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
957 | datestring = 'just now' |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
958 | elif delta.seconds < 3600: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
959 | minutes = delta.seconds / 60 |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
960 | datestring = '%d minute%s ago' % (minutes, plural (minutes)) |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
961 | else: |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
962 | hours = delta.seconds / 3600 |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
963 | datestring = '%d hour%s ago' % (hours, plural (hours)) |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
964 | else: |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
965 | datestring = '%d day%s ago' % (delta.days, plural (delta.days)) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
966 | else: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
967 | datestring = 'on %s' % (str (date)) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
968 | #fi |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
969 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
970 | self.privmsg (replyto, 'changeset %s (%s): committed by %s %s (%s)' % \ |
63
a1a864c25e42
- fixed: .cset didn't operate properly with dates
Teemu Piippo <crimsondusk64@gmail.com>
parents:
62
diff
changeset
|
971 | (node, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat)) |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
972 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
973 | for line in message.split ('\n'): |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
974 | self.privmsg (replyto, ' ' + line) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
975 | except hgapi.hgapi.HgException as e: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
976 | result = decipher_hgapi_error (e) |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
977 | |
58
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
978 | if result[0]: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
979 | self.privmsg (replyto, 'error: %s' % result[1]) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
980 | else: |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
981 | self.privmsg (replyto, 'error: %s' % `e`) |
577cecfea94e
- now able to get changeset by date
Teemu Piippo <crimsondusk64@gmail.com>
parents:
57
diff
changeset
|
982 | #tried |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
983 | # else: |
55
441a04262cb4
- added the .changeset (aka .cset or .rev) command to get revision info
Teemu Piippo <crimsondusk64@gmail.com>
parents:
54
diff
changeset
|
984 | # raise logical_exception ("unknown command `.%s`" % command) |
0 | 985 | |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
986 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
987 | # Print a ticket announce to appropriate channels |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
988 | # |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
989 | def announce_ticket (self, data): |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
990 | idstring = "%d" % data.id |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
991 | while len(idstring) < 7: |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
992 | idstring = "0" + idstring |
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
993 | |
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
|
994 | isprivate = data['view_state']['name'] == 'private' |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
995 | 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
|
996 | |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
997 | for channel in self.channels: |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
998 | if channel.get_value ('btannounce', False): |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
999 | if not isprivate or (channel.get_value ('btprivate', False)): |
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
|
1000 | self.write ("PRIVMSG %s :[%s] New issue %s, reported by %s: %s: %s" % \ |
68
ecc161d4a6fa
- fixed bad channel config addressing
Teemu Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
1001 | (channel.get_value ('name'), data['project']['name'], idstring, reporter, |
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
|
1002 | 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
|
1003 | #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
|
1004 | #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
|
1005 | #done |
12
e843c08ee51e
- added mantisbt new ticket announcing
Santeri Piippo <crimsondusk64@gmail.com>
parents:
11
diff
changeset
|
1006 | |
0 | 1007 | def handle_error(self): |
1008 | excepterm (traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) | |
1009 | ||
62
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
1010 | def restart(self): |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
1011 | excepterm('') |
052a8a1e3d7d
- revamped commands, added a much more modular system. not everything migrated yet
Teemu Piippo <crimsondusk64@gmail.com>
parents:
60
diff
changeset
|
1012 | |
0 | 1013 | def privmsg (self, channel, msg): |
1014 | self.write ("PRIVMSG %s :%s" % (channel, msg)) | |
1015 | ||
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1016 | def close_connection (self, message): |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1017 | 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
|
1018 | self.write ("QUIT :" + message) |
5
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1019 | self.send_all_now() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1020 | self.close() |
b6d2b7de0a6d
- added .restart and .update
Santeri Piippo <crimsondusk64@gmail.com>
parents:
4
diff
changeset
|
1021 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1022 | 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
|
1023 | 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
|
1024 | |
0 | 1025 | 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
|
1026 | self.close_connection ('Caught exception') |
0 | 1027 | |
1028 | 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
|
1029 | self.close_connection ('KeyboardInterrupt') |
0 | 1030 | |
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
|
1031 | # |
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
|
1032 | # 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
|
1033 | # |
0 | 1034 | try: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1035 | autoconnects = Config.get_value ('autoconnect', []) |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1036 | |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1037 | if len (autoconnects) == 0: |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1038 | print "Nowhere to connect." |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1039 | quit() |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1040 | |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1041 | for aconn in autoconnects: |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1042 | for conndata in Config.get_nodelist ('connections'): |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1043 | if conndata.get_value ('name') == aconn: |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1044 | 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
|
1045 | break |
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1046 | else: |
65
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1047 | raise ValueError ("unknown autoconnect entry %s" % (aconn)) |
20bd76353eb5
- modularized the configuration and made it more systematic
Teemu Piippo <crimsondusk64@gmail.com>
parents:
63
diff
changeset
|
1048 | |
26
580a2a9fd2e5
- made cobalt die if autoconnect entries cannot be found plus other stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
25
diff
changeset
|
1049 | g_BotActive = True |
0 | 1050 | asyncore.loop() |
1051 | except KeyboardInterrupt: | |
1052 | for client in g_clients: | |
1053 | client.keyboardinterrupt() | |
1054 | quit() |