Пример #1
0
    def handle(self, text, **options):
        try:
            user = os.getlogin()
        except OSError:
            user = pwd.getpwuid(os.geteuid())[0]

        message = handle(user, text)
        print format_incoming(message)
Пример #2
0
    def handle(self, path, **options):
        body = open(path).read()
        for index, entry in enumerate(yaml.load(body)):
            # parse time into naive datetime-object (UTC-local)
            time = iso8601.parse_date(entry["time"]).replace(tzinfo=None)
            name, ident = entry["uri"].split("://")

            try:
                message = handle(ident, entry["text"], time=time, name=name)
            except Exception, exc:
                print traceback.format_exc(exc)
                continue
            print format_incoming(message)