Sat, 18 Jul 2015 16:59:44 +0300
Include timestamp in console outputs
hgpoll.py | file | annotate | diff | comparison | revisions | |
irc.py | file | annotate | diff | comparison | revisions |
--- a/hgpoll.py Mon Jun 01 12:46:23 2015 +0300 +++ b/hgpoll.py Sat Jul 18 16:59:44 2015 +0300 @@ -511,7 +511,7 @@ + ColorChar + BoldChar + ']' + BoldChar ZDoomMin = 2560 -ZDoomMax = 3794 +ZDoomMax = 4341 def check_zdoom_upgrade (repo_name, commit_node): zanrepo = hgapi.Repo (repo_name) @@ -521,18 +521,6 @@ if newnumber > ZDoomRevNumber: ZDoomRevNumber = newnumber - fraction = float (newnumber - ZDoomMin) / (ZDoomMax - ZDoomMin) - # progressBar = make_progress_bar (fraction, 30, colored=True); - - message = """ZDoom upgrade: r%d: %d revisions left (%d%% complete)""" %\ - (newnumber, ZDoomMax - newnumber, round (fraction * 100)) - - for irc_client in Irc.all_clients: - for channel in irc_client.channels: - if not channel.get_value ('allpublishing', False): - continue - irc_client.privmsg (channel.get_value ('name'), message) - update_zadev_topic() except Exception as e: Irc.broadcast ('Error while dealing with ZDoom upgrade number: %s' % e) @@ -540,8 +528,8 @@ def update_zadev_topic(): return fraction = float (ZDoomRevNumber - ZDoomMin) / (ZDoomMax - ZDoomMin) - topicText = """ZDoom 2.6.1 progress: at r%d, %d revisions left (%d%% complete)""" %\ - (ZDoomRevNumber, ZDoomMax - ZDoomRevNumber, round (fraction * 100)) + topicText = """ZDoom r%d progress: at r%d, %d revisions left (%d%% complete)""" %\ + (ZDoomMax, ZDoomRevNumber, ZDoomMax - ZDoomRevNumber, round (fraction * 100)) try: Irc.ClientsByName['zandronum'].write ("""TOPIC #zadev :%s""" % topicText)
--- a/irc.py Mon Jun 01 12:46:23 2015 +0300 +++ b/irc.py Sat Jul 18 16:59:44 2015 +0300 @@ -33,6 +33,7 @@ import modulecore as ModuleCore import traceback import time +import datetime from configfile import Config import bt as Bt import hgpoll as HgPoll @@ -52,6 +53,9 @@ def __str__ (self): return self.message +def get_timestamp(): + return datetime.datetime.now().strftime ('%a %d %b %H:%M:%S') + # # Prints a line to log channel(s) # @@ -100,7 +104,7 @@ all_clients.append (self) asyncore.dispatcher.__init__ (self) self.create_socket (socket.AF_INET, socket.SOCK_STREAM) - print "Connecting to [%s] %s:%d..." % (self.name, self.host, self.port) + print "[%s] Connecting to [%s] %s:%d..." % (get_timestamp(), self.name, self.host, self.port) self.connect ((self.host, self.port)) ClientsByName[self.name] = self @@ -112,7 +116,7 @@ self.write ("NICK %s" % self.mynick) def handle_connect (self): - print "Connected to [%s] %s:%d" % (self.name, self.host, self.port) + print "[%s] Connected to [%s] %s:%d" % (get_timestamp(), self.name, self.host, self.port) self.register_to_irc() def write (self, utfdata): @@ -122,7 +126,7 @@ pass def handle_close (self): - print "Connection to [%s] %s:%d terminated." % (self.name, self.host, self.port) + print "[%s] Connection to [%s] %s:%d terminated." % (get_timestamp(), self.name, self.host, self.port) self.close() def handle_write (self): @@ -137,7 +141,7 @@ def send_all_now (self): for line in self.send_buffer: if self.verbose: - print "[%s] <- %s" % (self.name, line) + print "[%s] [%s] <- %s" % (get_timestamp(), self.name, line) self.send ("%s\n" % line) time.sleep (0.25) self.send_buffer = [] @@ -151,7 +155,7 @@ continue if self.verbose: - print "[%s] -> %s" % (self.name, line) + print "[%s] [%s] -> %s" % (get_timestamp(), self.name, line) if line.startswith ("PING :"): self.write ("PONG :%s" % line[6:])