Пример #1
0
 def run(self):
     # setup progress handler
     self.byteUpdate = time.time()
     self.recvTotal = 0
     def canPost():
         if (time.time() - self.byteUpdate) > 0.1:
             self.byteUpdate = time.time()
             return True
     def recvEvent(bytes):
         self.recvTotal += bytes
         if canPost():
             self.recv.emit()
     addHook("httpRecv", recvEvent)
     con =  httpCon()
     try:
         resp, cont = con.request(
             aqt.appShared + "download/%d" % self.code)
     except Exception as e:
         exc = traceback.format_exc()
         try:
             self.error = str(e[0])
         except:
             self.error = str(exc)
         return
     finally:
         remHook("httpRecv", recvEvent)
     if resp['status'] == '200':
         self.error = None
         self.fname = re.match("attachment; filename=(.+)",
                               resp['content-disposition']).group(1)
         self.data = cont
     elif resp['status'] == '403':
         self.error = _("Invalid code.")
     else:
         self.error = _("Error downloading: %s") % resp['status']
Пример #2
0
    def run(self):
        # setup progress handler
        self.byteUpdate = time.time()
        self.recvTotal = 0

        def canPost():
            if (time.time() - self.byteUpdate) > 0.1:
                self.byteUpdate = time.time()
                return True

        def recvEvent(bytes):
            self.recvTotal += bytes
            if canPost():
                self.emit(SIGNAL("recv"))

        addHook("httpRecv", recvEvent)
        con = httpCon()
        try:
            resp, cont = con.request(aqt.appShared + "download/%d" % self.code)
        except Exception, e:
            try:
                self.error = unicode(e[0], "utf8", "ignore")
            except:
                self.error = traceback.format_exc()
            return
Пример #3
0
    def run(self):
        # setup progress handler
        self.byteUpdate = time.time()
        self.recvTotal = 0

        def canPost():
            if (time.time() - self.byteUpdate) > 0.1:
                self.byteUpdate = time.time()
                return True

        def recvEvent(bytes):
            self.recvTotal += bytes
            if canPost():
                self.recv.emit()

        addHook("httpRecv", recvEvent)
        con = httpCon()
        try:
            resp, cont = con.request(aqt.appShared + "download/%d" % self.code)
        except Exception, e:
            exc = traceback.format_exc()
            try:
                self.error = unicode(e[0], "utf8", "ignore")
            except:
                self.error = unicode(exc, "utf8", "ignore")
            return
Пример #4
0
 def run(self):
     # setup progress handler
     self.byteUpdate = time.time()
     self.recvTotal = 0
     def canPost():
         if (time.time() - self.byteUpdate) > 0.1:
             self.byteUpdate = time.time()
             return True
     def recvEvent(bytes):
         self.recvTotal += bytes
         if canPost():
             self.emit(SIGNAL("recv"), self.recvTotal)
     addHook("httpRecv", recvEvent)
     con =  httpCon()
     try:
         resp, cont = con.request(
             aqt.appShared + "download/%d" % self.code)
     except Exception, e:
         self.error = unicode(e)
         return
Пример #5
0
def setup_remoteMedia():
    setup_basic()
    con = httpCon()
    ts.server = RemoteMediaServer(TEST_HKEY, con)
    ts.server2 = RemoteServer(TEST_HKEY)
    ts.client = MediaSyncer(ts.deck1, ts.server)
Пример #6
0
def setup_remoteMedia():
    setup_basic()
    con = httpCon()
    ts.server = RemoteMediaServer(TEST_HKEY, con)
    ts.server2 = RemoteServer(TEST_HKEY)
    ts.client = MediaSyncer(ts.deck1, ts.server)