Пример #1
0
    def run(self):
        with open(FILE_DIR + '/' + self.fpath, 'r') as f:
            e = Event(pdu.cUpdSending)
            e["file"] = self.fpath
            while True:
                message=e.read_data_and_encode(f, MTU)
                if len(message) > 0:
                    self.channel.send(message)
                    continue

                e = Event(pdu.cUpdFinished)
                e["file"] = self.fpath
#######INCOMPLETE

                #chunk = f.read(siz)
                #print repr(chunk)
                #if not chunk: break
                #e = Event(pdu.cUpdSending, chunk)
                self.channel.send(e.encode())
            self.channel.send(Event(pdu.cUpdSendDone).encode())
Пример #2
0
e = icalendar.Event()
e['uid'] = '32'
e.add('dtstart', a.naive)
e['dtend'] = 'dad'
cal.add_component(e)

print(cal.to_ical())

print(a.naive)
evt = Event(a, a, 2, 1, 2, 2)
e1 = Event(a, a, 2, 1, 22, 22)
t = Task(a, 2, 3, 4, 5, 6)
t1 = Task(a, 2, 3, 4, 52, 21)

with open('active_events.txt', "w") as f:
    f.write("{}\n".format(evt.encode()))
    f.write("{}\n".format(e1.encode()))

with open('active_events.txt', "r") as f:
    lines = f.readlines()
    for line in lines:
        e = Event.decode(line)
        print(e)
        print(type(e))

try:
    foo()
    print("bar")
except:
    raise