def read(self) -> typing.Optional[typing.List[str]]: lines = self.socket.read() if lines: self.ping_sent = False now = datetime.datetime.utcnow() self.set_setting("last-read", utils.iso8601_format(now)) return lines
def read(self) -> typing.Optional[typing.List[str]]: lines = self.socket.read() if lines: self.ping_sent = False now = datetime.datetime.utcnow() self.set_setting("last-read", utils.iso8601_format(now, milliseconds=True)) return lines
def upsert_badge(self, event): """ :help: Add or update a badge :usage: <badge> today|<yyyy-mm-dd> """ badge = " ".join(event["args_split"][:-1]) badge_lower = badge.lower() badges = self._get_badges(event["user"]) found_badge = self._find_badge(badges, badge) dt = self._parse_date(event["args_split"][-1]) badges[found_badge or badge] = utils.iso8601_format(dt) self._set_badges(event["user"], badges) add_or_update = "Added" if not found_badge else "Updated" event["stdout"].write("%s '%s' badge to %s" % (add_or_update, badge, self._date_str(dt)))
def upsert_badge(self, event): """ :help: Add or update a badge :usage: <badge> today|<yyyy-mm-dd> """ badge = " ".join(event["args_split"][:-1]) badge_lower = badge.lower() badges = self._get_badges(event["user"]) found_badge = self._find_badge(badges, badge) dt = self._parse_date(event["args_split"][-1]) badges[found_badge or badge] = utils.iso8601_format(dt) self._set_badges(event["user"], badges) add_or_update = "Added" if not found_badge else "Updated" event["stdout"].write("%s '%s' badge to %s" % ( add_or_update, badge, self._date_str(dt)))
def update_badge(self, event): """ :help: Change the date of a badge :usage: <badge> today|<yyyy-mm-dd> """ badge = " ".join(event["args_split"][:-1]) badge_lower = badge.lower() badges = self._get_badges(event["user"]) found_badge = self._find_badge(badges, badge) if not found_badge: raise utils.EventError("You have no '%s' badge" % badge) dt = self._parse_date(event["args_split"][-1]) badges[found_badge] = utils.iso8601_format(dt) self._set_badges(event["user"], badges) event["stdout"].write("Updated '%s' badge to %s" % (found_badge, self._date_str(dt)))
def update_badge(self, event): """ :help: Change the date of a badge :usage: <badge> today|<yyyy-mm-dd> """ badge = " ".join(event["args_split"][:-1]) badge_lower = badge.lower() badges = self._get_badges(event["user"]) found_badge = self._find_badge(badges, badge) if not found_badge: raise utils.EventError("You have no '%s' badge" % badge) dt = self._parse_date(event["args_split"][-1]) badges[found_badge] = utils.iso8601_format(dt) self._set_badges(event["user"], badges) event["stdout"].write("Updated '%s' badge to %s" % ( found_badge, self._date_str(dt)))
def formatTime(self, record, datefmt=None): datetime_obj = datetime.datetime.fromtimestamp(record.created) return utils.iso8601_format(datetime_obj, milliseconds=True)
def lock(self): with open(self._filename, "w") as lock_file: last_lock = utils.datetime_utcnow() lock_file.write("%s" % utils.iso8601_format(last_lock)) self._next_lock = last_lock + datetime.timedelta( seconds=EXPIRATION / 2)
def formatTime(self, record, datefmt=None): datetime_obj = datetime.datetime.fromtimestamp(record.created) return utils.iso8601_format(datetime_obj, milliseconds=True)