Esempio n. 1
0
    def run(self):
        while True:
            url,tone_name= self.q.get()

            doc = pq(url)
            download_url = pq(doc.find("a#xiazai")[0]).attr("href")
            BeanManager.add_bean(bt = "ring_tone" , url = url , filename = tone_name)

            self.q.task_done()
            print "I am robot %s, %s done" %(self.name , tone_name)
Esempio n. 2
0
 def collect_diary(self,diary_type):
     print "init reader"
     reader = ReaderFactory.getReader(diary_type)
     print "begin reading"
     beans = reader.read()
     bm = BeanManager()
     print "adding beans"
     for b in beans:
         print "adding",b
         bm.add_bean(**b)
Esempio n. 3
0
        def wrapper(**kwargs):
            if re.match("show_.+" , attr):
                _ , what = attr.split("_")
                time = kwargs["time"]
                random = kwargs["random"]

                from_t,to_t = get_range_from_string(time)
                
                kwargs = {
                    "bt":what,
                    "when_created":{
                        "$gt":from_t,
                        "$lt":to_t
                    }
                }
                return BM.get_beans(kwargs)
Esempio n. 4
0
def download_tone(url,tone_name):
    doc = pq(url)
    download_url = pq(doc.find("a#xiazai")[0]).attr("href")
    BeanManager.add_bean(bt = "ring_tone" , url = download_url , filename = tone_name)
Esempio n. 5
0
 def clean_diary(self):
     bm = BeanManager()
     bm.clean_beans()