Пример #1
0
def openSocket(addr,port,sockNum,userID,userPassword,protocol,RUN_MODE):
    #Function Open a socket and responds with CONNECT/NO CARRIER/ERROR

    try:
        #Close Socket
        res = sendAtCmd('AT#SS',properties.CMD_TERMINATOR,0,20)
        if (res!="#SS: 1,0"):
            res = sendAtCmd('AT#SH=1',properties.CMD_TERMINATOR,0,20)

        if (res=='ERROR'):
            return
        
        #Activate PDP if needed  
        res = sendAtCmd('AT#SGACT?',properties.CMD_TERMINATOR,0,20) 
        if (res!="#SGACT: 1,1"):
            delaySec(1)
            res = sendAtCmd('AT#SGACT=1,1,"' + str(userID) + '","' + str(userPassword) + '"' ,properties.CMD_TERMINATOR,0,180)
            DEBUG.sendMsg(res + '\r\n',RUN_MODE) 

        if (res=='ERROR'):
            return            

        #Open Socket to Server
        if (str(protocol)=='TCPIP'):
            res = sendAtCmd('AT#SD=1,0,' + port + ',"' + addr + '",0','CONNECT\r\n',0,180)
        else:
            res = sendAtCmd('AT#SD=1,1,' + port + ',"' + addr + '",0,5559','CONNECT\r\n',0,180)

    except:
        print 'Script encountered an exception.'
        print 'Exception Type: ' + str(sys.exc_type)
        print 'MODULE -> ATC'
        print 'METHOD -> openSocket(' + addr + ',' + port + ',' + sockNum + ',' + userID + ',' + userPassword + ',' + protocol + ')'

    return res
Пример #2
0
 def __getResponeResult(self, url):
     try:
         login_data = urllib.urlencode({})
         login_headers = {
             'Referer': url,
             'User-Agent': 'Opera/9.60',
         }
         login_request = urllib2.Request(url, login_data, login_headers)
         result = urllib2.urlopen(login_request, data=None,
                                  timeout=30).read()
         return json.loads(result.decode("utf-8"))['results']
     except:
         DEBUG.p('get data failed, and try again...')
         try:
             login_data = urllib.urlencode({})
             login_headers = {
                 'Referer': url,
                 'User-Agent': 'Opera/9.60',
             }
             login_request = urllib2.Request(url, login_data, login_headers)
             result = urllib2.urlopen(login_request, data=None,
                                      timeout=30).read()
             return json.loads(result.decode("utf-8"))['results']
         except:
             DEBUG.p('err: get data failed from: %s' % (url))
             result = []
             return result
Пример #3
0
    def getInfosWithAlbum_deepdeep(self, albumName, country, limit=50):
        if not albumName:
            DEBUG.p('Please special the album name')
            return false
        if not country:
            DEBUG.p('country undefine, use "us" as defaulted')
            country = 'us'
        if limit != 50:
            self.limit = int(limit)

        infos = []
        #get all albums of name 'albumName'
        jsonResultAlbums = self.__getInfoByAlbumName(albumName, country)
        for jsonResultAlbum in jsonResultAlbums:
            ret = self.__saveAllInfos(jsonResultAlbum, country)
            if not ret:
                continue
            infos.append(ret)

            #get all albums of the artist
            infos.extend(
                self.getInfosWithAritstName_deep(jsonResultAlbum['artistName'],
                                                 country, limit))
            #get all albums of the album
            infos.extend(
                self.getInfosWithAlbumName_deep(
                    jsonResultAlbum['collectionName'], country, limit))
        return infos
Пример #4
0
 def __getMusicLists(self, albumName, country):
     #get album musics info
     url = self.baseUrl + 'term=%s&country=%s&media=music&limit=%d'%(albumName, country, self.limit)
     #DEBUG.p(url)
     jsonResultMusics = self.__getResponeResult(url)
     DEBUG.p('result count: %d'%(len(jsonResultMusics)))
     return jsonResultMusics
Пример #5
0
 def __getMusicLists(self, albumName, country):
     #get album musics info
     url = self.baseUrl + 'term=%s&country=%s&media=music&limit=%d' % (
         albumName, country, self.limit)
     #DEBUG.p(url)
     jsonResultMusics = self.__getResponeResult(url)
     DEBUG.p('result count: %d' % (len(jsonResultMusics)))
     return jsonResultMusics
Пример #6
0
def main():
    # total number of interactions between 1 and infinity
    validInter = False # flag for a valid user input
    while validInter == False:
        try:
            totalInter = int(input("Enter total number of interactions (greater than or equal to 1): "))
        except ValueError:
            print("Do not enter non-numeric values.")
        else:
            if (totalInter >= 1):
                validInter = True
            else:
                validInteractions = False
                print("Input is out of range.")
    # Set the target's probability of X or Y
    validProb = False # flag for a valid user input
    while validProb == False:
        try:
            probX = int(input("Probability of X-type Interactions for the target (1-100): "))
        except ValueError:
            print("Do not enter non-numeric values.")
        else:
            if (1 <= probX <= 100):
                validProb = True
            else:
                validProb = False
                print("Input is out of range.")
    probY = 100 - probX # probabilty of Y interactions
    #DEBUG
    DEBUG.dprint("total # interactions: %r" % totalInter)
    DEBUG.dprint("probability of X: %r" % probX)
    # Pursuer class takes the two probabilities
    aPursuer = Pursuer(totalInter)
    aTarget = Target(probX, probY)
    # Main Loop
    i = 0 # flag
    while i < totalInter:
        # create an interaction for the pursuer and the target
        interP = aPursuer.createInteraction()
        interT = aTarget.createInteraction()
        # DEBUG
        DEBUG.dprint("aPursuer Interaction: %r" % interP)
        DEBUG.dprint("aTarget Interaction: %r" % interT)
        DEBUG.dprint("i: %r" % i)
        # record and display the result
        result = aPursuer.reportInteraction(interP, interT)
        print(result)
        i += 1 # update flag
        if i >= 2:
            aPursuer.adaptBehaviour(interP, interT)
    targetX, targetY = aTarget.reportEnd()
    aPursuer.reportEnd(targetX, targetY)
Пример #7
0
    def __init__(self):
        try:
            self.__server = Server()
        except:
            print 'can not connect to Couchdb:%s' % (settings.c['db_url'])

        self.__db = {}
        self.__db_name = settings.c['db_name']
        DEBUG.p(self.__db_name.items())
        for (k, v) in self.__db_name.items():
            try:
                self.__db[v] = self.__server.create(v)
            except:
                self.__db[v] = self.__server[v]
Пример #8
0
    def __init__(self):
        try:
            self.__server = Server()
        except:
            print 'can not connect to Couchdb:%s'%(settings.c['db_url'])

        self.__db = {} 
        self.__db_name = settings.c['db_name']
        DEBUG.p(self.__db_name.items())
        for (k, v) in self.__db_name.items():
            try:
                self.__db[v] = self.__server.create(v)
            except:
                self.__db[v] = self.__server[v]
Пример #9
0
def make_dir():
        name = "Waldemar Matuska, Karel \xc4\x8cernoch, Lenka Filipova, Karel Gott, Karel H\xc3\xa1la, Ji\xc5\x99\xc3\xad \xc5\xa0t\xc4\x9bdro\xc5\x88, Felix Slov\xc3\xa1\xc4\x8dek, Na\xc4\x8fa Urb\xc3\xa1nkov\xc3\xa1, Helena Vondr\xc3\xa1\xc4\x8dkov\xc3\xa1, Hana Zagorov\xc3\xa1, Karel V\xc3\xa1gner Se Sv\xc3\xbdm Orchestrem, Ladislav \xc5\xa0Taidl Se Sv\xc3\xbdm Orchestrem, Orchestr \xc4\x8cs. televize & Tane\xc4\x8dn\xc3\xad"
        print len(name)
        print name[0:254]
        artist_dir = os.getcwd()
        dir_len = len(name)
        if dir_len > 255:
            album_dir = artist_dir + '/' + name[0:254]
        else:
            album_dir = artist_dir + '/' + name

        if not os.path.exists(album_dir):
           os.makedirs(album_dir)
        else:
           DEBUG.p('this album info exist!!!!')
Пример #10
0
def make_dir():
    name = "Waldemar Matuska, Karel \xc4\x8cernoch, Lenka Filipova, Karel Gott, Karel H\xc3\xa1la, Ji\xc5\x99\xc3\xad \xc5\xa0t\xc4\x9bdro\xc5\x88, Felix Slov\xc3\xa1\xc4\x8dek, Na\xc4\x8fa Urb\xc3\xa1nkov\xc3\xa1, Helena Vondr\xc3\xa1\xc4\x8dkov\xc3\xa1, Hana Zagorov\xc3\xa1, Karel V\xc3\xa1gner Se Sv\xc3\xbdm Orchestrem, Ladislav \xc5\xa0Taidl Se Sv\xc3\xbdm Orchestrem, Orchestr \xc4\x8cs. televize & Tane\xc4\x8dn\xc3\xad"
    print len(name)
    print name[0:254]
    artist_dir = os.getcwd()
    dir_len = len(name)
    if dir_len > 255:
        album_dir = artist_dir + '/' + name[0:254]
    else:
        album_dir = artist_dir + '/' + name

    if not os.path.exists(album_dir):
        os.makedirs(album_dir)
    else:
        DEBUG.p('this album info exist!!!!')
Пример #11
0
    def getInfosWithAritstName_deep(self, artistName, country, limit=50):
        if not artistName:
            DEBUG.p('Please special the artist name')
            return false
        if not country:
            DEBUG.p('country undefine, use "us" as defaulted')
            country = 'us'
        if limit != 50:
            self.limit = int(limit)

        infos = []
        #get all albums of the artist
        jsonResultAlbums = self.__getInfoByArtistName(artistName, country)
        for jsonResultAlbum in jsonResultAlbums:
            ret = self.__saveAllInfos(jsonResultAlbum, country)
            if not ret:
                continue
            infos.append(ret)
            #enter db

            #get all albums of other artist
            if jsonResultAlbum['artistName'] != artistName:
                jsonAlbums = self.__getInfoByArtistName(
                    jsonResultAlbum['artistName'], country)
                for jsonAlbum in jsonAlbums:
                    ret = self.__saveAllInfos(jsonAlbum, country)
                    if not ret:
                        continue
                    infos.append(ret)

                    jsonResultAlbums2 = self.__getInfoByAlbumName(
                        jsonAlbum['collectionName'], country)
                    for jsonResultAlbum2 in jsonResultAlbums2:
                        ret = self.__saveAllInfos(jsonResultAlbum2, country)
                        if not ret:
                            continue
                        infos.append(ret)

                        jsonAlbums2 = self.__getInfoByArtistName(
                            jsonResultAlbum2['artistName'], country)
                        for jsonAlbum2 in jsonAlbums2:
                            ret = self.__saveAllInfos(jsonAlbum2, country)
                            if not ret:
                                continue
                            infos.append(ret)

        return infos
Пример #12
0
    def getInfosWithAritstName_deep(self, artistName, country, limit = 50):
        if not artistName:
           DEBUG.p('Please special the artist name')
           return false 
        if not country:
           DEBUG.p('country undefine, use "us" as defaulted')
           country = 'us'
        if limit != 50:
           self.limit = int(limit)

        infos = []
        #get all albums of the artist
        jsonResultAlbums = self.__getInfoByArtistName(artistName, country)
        for jsonResultAlbum in jsonResultAlbums:
            ret = self.__saveAllInfos(jsonResultAlbum, country)
            if not ret: 
               continue
            infos.append(ret) 
            #enter db

            #get all albums of other artist
            if jsonResultAlbum['artistName'] != artistName:
                    jsonAlbums = self.__getInfoByArtistName(jsonResultAlbum['artistName'], country)
                    for jsonAlbum in jsonAlbums:
                        ret = self.__saveAllInfos(jsonAlbum, country)
                        if not ret:
                           continue
                        infos.append(ret) 

                        jsonResultAlbums2 = self.__getInfoByAlbumName(jsonAlbum['collectionName'], country)
                        for jsonResultAlbum2 in jsonResultAlbums2:
                            ret = self.__saveAllInfos(jsonResultAlbum2, country)
                            if not ret:
                               continue
                            infos.append(ret) 

                            jsonAlbums2 = self.__getInfoByArtistName(jsonResultAlbum2['artistName'], country)
                            for jsonAlbum2 in jsonAlbums2:
                                ret = self.__saveAllInfos(jsonAlbum2, country)
                                if not ret:
                                   continue
                                infos.append(ret) 

        return infos
Пример #13
0
 def __getResponeResult(self, url):
     try:
         login_data = urllib.urlencode({})
         login_headers = {'Referer':url, 'User-Agent':'Opera/9.60',}
         login_request = urllib2.Request(url, login_data, login_headers)
         result = urllib2.urlopen(login_request, data=None, timeout=30).read()
         return json.loads(result.decode("utf-8"))['results']
     except:
         DEBUG.p('get data failed, and try again...')
         try:
             login_data = urllib.urlencode({})
             login_headers = {'Referer':url, 'User-Agent':'Opera/9.60',}
             login_request = urllib2.Request(url, login_data, login_headers)
             result = urllib2.urlopen(login_request, data=None, timeout=30).read()
             return json.loads(result.decode("utf-8"))['results']
         except:
             DEBUG.p('err: get data failed from: %s' % (url))
             result = []
             return result
Пример #14
0
    def getInfosWithAlbumName(self, albumName, country, limit = 50):
        if not albumName:
           DEBUG.p('Please special the album name')
           return false 
        if not country:
           DEBUG.p('country undefine, use "us" as defaulted')
           country = 'us'
        if limit != 50:
           self.limit = int(limit)

        infos = []
        #get all albums of name 'albumName' 
        jsonResultAlbums = self.__getInfoByAlbumName(albumName, country)
        for jsonResultAlbum in jsonResultAlbums:
            ret = self.__saveAllInfos(jsonResultAlbum, country)
            if not ret: 
               continue
            infos.append(ret) 

        return infos
Пример #15
0
    def __getInfoByArtistName(self, artistName, country):
        if not artistName:
           DEBUG.p('Please special the artist name')
           return false 
        if not country:
           DEBUG.p('country undefine, use "us" as defaulted')
           country = 'us'

        url = self.baseUrl + 'term=%s&country=%s&media=music&entity=album&limit=%d'%(artistName, country, self.limit)
        DEBUG.p(url)
        jsonResultAlbums = self.__getResponeResult(url)
        DEBUG.p('result count: %d'%(len(jsonResultAlbums)))
        return jsonResultAlbums
Пример #16
0
    def getInfosWithArtistName(self, artistName, country, limit=50):
        if not artistName:
            DEBUG.p('Please special the artist name')
            return false
        if not country:
            DEBUG.p('country undefine, use "us" as defaulted')
            country = 'us'
        if limit != 50:
            self.limit = int(limit)

        infos = []
        #get all albums of the artist
        jsonResultAlbums = self.__getInfoByArtistName(artistName, country)
        for jsonResultAlbum in jsonResultAlbums:
            ret = self.__saveAllInfos(jsonResultAlbum, country)
            if not ret:
                continue
            infos.append(ret)

        return infos
Пример #17
0
    def __getInfoByArtistName(self, artistName, country):
        if not artistName:
            DEBUG.p('Please special the artist name')
            return false
        if not country:
            DEBUG.p('country undefine, use "us" as defaulted')
            country = 'us'

        url = self.baseUrl + 'term=%s&country=%s&media=music&entity=album&limit=%d' % (
            artistName, country, self.limit)
        DEBUG.p(url)
        jsonResultAlbums = self.__getResponeResult(url)
        DEBUG.p('result count: %d' % (len(jsonResultAlbums)))
        return jsonResultAlbums
Пример #18
0
    def getInfosWithAlbumNameAndArtistName(self,
                                           albumName,
                                           artistName,
                                           country,
                                           limit=50):
        if not albumName and not artistName:
            DEBUG.p('Please special the album name and artist name')
            return false
        if not country:
            DEBUG.p('country undefine, use "us" as defaulted')
            country = 'us'
        if limit != 50:
            self.limit = int(limit)

        infos = []
        #get all albums of name 'albumName'
        jsonResultAlbums = self.__getInfoByArtistName(artistName, country)
        for jsonResultAlbum in jsonResultAlbums:
            DEBUG.p('albumName:%s; collectionName:%s' %
                    (albumName, jsonResultAlbum['collectionName']))
            if jsonResultAlbum['collectionName'] == albumName:
                ret = self.__saveAllInfos(jsonResultAlbum, country)
                if not ret:
                    continue
                infos.append(ret)

        return infos
Пример #19
0
def initGPRS (PDPindex,APN,userID,userPassword,RUN_MODE):

    try:        
        
        #Define GPRS Settings, MUST change APN String in script for your Carrier Specific setting
        res = sendAtCmd('AT+CGDCONT=' + str(PDPindex) + ',"IP","' + str(APN) + '","0.0.0.0",0,0' ,properties.CMD_TERMINATOR,0,20)
        #How long does system wait before sending undersized packet measured in 100ms settings
        res = sendAtCmd('AT#DSTO=10' ,properties.CMD_TERMINATOR,0,20)

        #Define Min/required Quality of Service
        res = sendAtCmd('AT+CGQMIN=1,0,0,0,0,0' ,properties.CMD_TERMINATOR,0,20)
        res = sendAtCmd('AT+CGQREQ=1,0,0,3,0,0' ,properties.CMD_TERMINATOR,0,20)

        #escape guard time, after set time escape sequence is excepted, set in 20ms settings
        res = sendAtCmd('ATS12=40' ,properties.CMD_TERMINATOR,0,20)

        #disable the escape sequence from transmitting during a data session
        res = sendAtCmd('AT#SKIPESC=1' ,properties.CMD_TERMINATOR,0,20)

        #Set connect timeOuts and packet sizes for PDP#1 and Socket#1
        res = sendAtCmd('AT#SCFG=1,1,512,90,100,50' ,properties.CMD_TERMINATOR,0,20)
        
        #Activate PDP if needed  
        res = sendAtCmd('AT#SGACT?',properties.CMD_TERMINATOR,0,20) 
        if (res!="#SGACT: 1,1"):
            delaySec(1)
            res = sendAtCmd('AT#SGACT=1,1,"' + str(userID) + '","' + str(userPassword) + '"' ,properties.CMD_TERMINATOR,0,180)
            DEBUG.sendMsg(res + '\r\n',RUN_MODE) 

        if (res=='ERROR'):
            return  
        
    except:
        print 'Script encountered an exception.'
        print 'Exception Type: ' + str(sys.exc_type)
        print 'MODULE -> ATC'
        print 'METHOD -> initGPRS(' + PDPindex + ',' + APN + ',' + res + ')'

    return    
Пример #20
0
def __saveCoverImage(albumDir, coverImageUrl):
        try:
            f = urllib2.urlopen(coverImageUrl)
            with open(albumDir + '/' + coverImageUrl.split('/')[-1], 'wb') as code:
                code.write(f.read())
            DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1])) 
        except:
            DEBUG.p('%s Pic Saved failed! and try again...' % (coverImageUrl.split('/')[-1])) 
            try:
                f = urllib2.urlopen(coverImageUrl)
                with open(albumDir + '/' + coverImageUrl.split('/')[-1], 'wb') as code:
                    code.write(f.read())
                DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1])) 
            except:
                DEBUG.p('err: %s Pic Saved failed!' % (coverImageUrl.split('/')[-1])) 
Пример #21
0
def __saveCoverImage(albumDir, coverImageUrl):
    try:
        f = urllib2.urlopen(coverImageUrl)
        with open(albumDir + '/' + coverImageUrl.split('/')[-1], 'wb') as code:
            code.write(f.read())
        DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1]))
    except:
        DEBUG.p('%s Pic Saved failed! and try again...' %
                (coverImageUrl.split('/')[-1]))
        try:
            f = urllib2.urlopen(coverImageUrl)
            with open(albumDir + '/' + coverImageUrl.split('/')[-1],
                      'wb') as code:
                code.write(f.read())
            DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1]))
        except:
            DEBUG.p('err: %s Pic Saved failed!' %
                    (coverImageUrl.split('/')[-1]))
Пример #22
0
    def POST_old(self):
        data = web.input(path={}) 

        coverPath = ''
        needMv = 0
        if data.coverurl:
            DEBUG.p(data.coverurl)
            coverPath = borrowData.getAlbumImageFromUrl(data.coverurl) 
            if len(coverPath) <= 0:
               return 'sorry, get image failed...'
        elif data.path.filename:
            filename = data.path.filename.replace('\\','/')
            coverPath = os.getcwd() +'/static/images/'+ filename
            fout = open(coverPath, 'wb')
            fout.write(data.path.file.read())
            needMv = 0
        else:
            return 'please input the file or coverurl!'

        newInstance = img.getImgInfo(coverPath)
            

        if data.path:
           newInstance['name'] = data.path
           newInstance['path'] = os.getcwd() + '/static/images/' + data.path

        newInstance['des'] = data.des

        if data.ximiurl:
           #musics list
           musics = borrowData.getMusicListFromXiMi(data.ximiurl) 
           print ','.join(musics)
           newInstance['music_contain'] = ';'.join(musics) 
           
           #artist, album_name, year_record
           (newInstance['artist'], newInstance['album_name'], newInstance['year_record']) = borrowData.getArtistAndAlbumFromXiMi(data.ximiurl)          
        else:
           newInstance['artist'] = data.artist
           newInstance['album_name'] = data.album_name
           newInstance['year_record'] = data.year_record
           newInstance['music_contain'] = data.music_contain

        if needMv and newInstance['artist'] and newInstance['album_name']:
           artist_dir = os.getcwd() + '/static/images/' + newInstance['artist'] 
           album_dir = artist_dir + '/' + newInstance['album_name'] 
           if not os.path.exists(artist_dir):
              os.makedirs(artist_dir)
           if not os.path.exists(album_dir):
              os.makedirs(album_dir)
           shutil.move(coverPath, album_dir)
           

        print 'ximiurl: ' + data.ximiurl 
        print 'name: ' + newInstance['name'] 
        print 'album_name: ' + newInstance['album_name']
        print 'artist: ' + newInstance['artist'] 
        print 'year_record' + newInstance['year_record'] 
        print 'des: ' + newInstance['des'] 
        print 'music_contain: ' + newInstance['music_contain'] 
        print 'path: ' + newInstance['path']
        try:
           dao.inster_instance(newInstance)
        except:
           print 'dao.inster_instance failed!'
           print traceback.print_exc() 

        return self.render.coverShow(newInstance)
Пример #23
0
    def POST(self):
        data = web.input(path={}) 
        if data.limit:
           limit = int(data.limit)

        #itunes api
        if data.album_name or data.artist_name:
            if data.country == 'deep' and data.album_name:
               DEBUG.p('get deep creep: %s' % (data.album_name))
               infos = itunesapi.getInfosWithAlbumName_deep(data.album_name, None, data.limit)
            elif data.country == 'deep' and data.artist_name:
               DEBUG.p('get deep creep: %s' % (data.artist_name))
               infos = itunesapi.getInfosWithAritstName_deep(data.artist_name, None, data.limit)
            elif data.album_name and data.artist_name:
               DEBUG.p('get %s by %s' % (data.album_name, data.artist_name))
               infos = itunesapi.getInfosWithAlbumNameAndArtistName(data.album_name, data.artist_name, data.country, data.limit)
            elif data.album_name: 
               DEBUG.p('get album: %s' % (data.album_name))
               infos = itunesapi.getInfosWithAlbumName(data.album_name, data.country, data.limit)
            elif data.artist_name: 
               DEBUG.p('get album by %s' % (data.artist_name))
               infos = itunesapi.getInfosWithArtistName(data.artist_name, data.country, data.limit)
        else:
            DEBUG.p("empty album name or drtist name!")
            infos = [{
                'album_name': '',
                'artist': '',
                'year_record': '12345',
                'music_contain': 'Nothing',
                'path': u'static/images/onePiece.png',
                'cover_name_1200': u'onePiece.png',
                'cover_name_170': u'onePiece.png',
                'cover_name_100': u'onePiece.png',
                'copy_right': u'lewis',
                'track_count': 1,
                'width': 0,
                'height': 0,
                'size': 0,
                'format': 'png',
                'des':'come on boy!!! day day up!!!',
                'url': ''},
                {'album_name': '',
                'artist': '',
                'year_record': '12345',
                'music_contain': 'Nothing',
                'path': u'static/images/onePiece.png',
                'cover_name_1200': u'onePiece.png',
                'cover_name_170': u'onePiece.png',
                'cover_name_100': u'onePiece.png',
                'copy_right': u'lewis',
                'track_count': 1,
                'width': 0,
                'height': 0,
                'size': 0,
                'format': 'png',
                'des':'come on boy!!! day day up!!!',
                'url': ''
            }]
        return self.render.coverShow(infos)
Пример #24
0
import Graphics
import matrix 
import DEBUG
import MatGraph
import math
from Mesh import *
import random
from typing import List
from dataclasses import dataclass
import threading
DEBUG.init()
Graphics.initDisplayHandler(DEBUG.window,(1920,1080),100,30*math.pi/180)


def PointAt(pos,target,up):
    
    
    NewForward = target-pos
    #print(NewForward.v)
    try:
        size = math.sqrt(NewForward.v[0]**2+NewForward.v[0]**2+NewForward.v[0]**2)
        NewForward.v[0] /= size
        NewForward.v[1] /= size
        NewForward.v[2] /= size
    except:
        pass

    
    
    a = NewForward * MatGraph.DotProduct(up,NewForward)
    NewUp = up - a
Пример #25
0
 def __saveCoverImage(self, album_dir, coverImageUrl):
     try:
         #f = urllib2.urlopen(coverImageUrl)
         #with open(album_dir + '/' + coverImageUrl.split('/')[-1], 'wb') as code:
         #    code.write(f.read())
         data = urllib2.urlopen(coverImageUrl, data=None, timeout=20).read()
         DEBUG.p('got data:')
         f = open(album_dir + '/' + coverImageUrl.split('/')[-1], 'wb')
         f.write(data)
         DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1]))
         f.close()
         return 1
     except:
         DEBUG.p('%s Pic Saved failed! and try again...' %
                 (coverImageUrl.split('/')[-1]))
         try:
             data = urllib2.urlopen(coverImageUrl, data=None,
                                    timeout=40).read()
             DEBUG.p('got data:')
             f = open(album_dir + '/' + coverImageUrl.split('/')[-1], 'wb')
             f.write(data)
             DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1]))
             f.close()
             return 1
         except:
             DEBUG.p('err: %s Pic Saved failed!' %
                     (coverImageUrl.split('/')[-1]))
             #remove failed-file
             if os.path.exists(album_dir + '/' +
                               coverImageUrl.split('/')[-1]):
                 os.remove(album_dir + '/' + coverImageUrl.split('/')[-1])
             f = open(
                 album_dir + '/' + coverImageUrl.split('/')[-1] + ".failed",
                 "w")
             f.close()
             #save music url into json file
             file = open(os.getcwd() + '/static/failed_url', "ab")
             json.dump((coverImageUrl, album_dir), file)
             file.close()
             return 0
Пример #26
0
def main():
    sys.path.append(".")
    import DEBUG
    global Cam
    global Light

    #t = threading.Thread(target = ui)
    #t.start()

    sol = []

    Step = 2
    Size = 30
    for i in range(-Size, Size, Step):
        for j in range(-Size, Size, Step):
            sq1 = matrix.mat3x3([[i, j, 3], [i, j + Step, 3], [i + Step, j,
                                                               3]])
            """
            sq2 = matrix.mat3x3([
                [i,j+Step,1],
                [i+Step,j+Step,1],
                [i+Step,j,1]
            ])"""

            sol.append(sq1)
            #sol.append(sq2)

    MatGraph.MultiplyMeshAndMatrix(sol,
                                   matrix.RotationMatrix("X", math.pi / 2))

    global TranslationMatrix

    DEBUG.init()
    Graphics.initDisplayHandler(DEBUG.window, DEBUG.ScreenSize, 100,
                                15 * math.pi / 180)
    DEBUG.HandleWindowEvents()
    theta = 0
    phi = 0
    vtheta = 0
    #for p in sys.path:

    #Test2 = Load3DElement("GPlaneur/Tests/Graphipsa3D/MeshFiles/GAMIIIING.obj")

    #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Y",theta))
    #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("X",math.pi/6))
    #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Z",math.pi/6))

    #Test2 = Load3DElement("Tests/Graphipsa3D/MeshFiles/teapot.obj")

    Cam = vector([0, 0, 0])
    vUp = vector([0, 1, 0])
    vLookDir = vector([0, 0, 1])
    vTarget = vector([0, 0, 1])

    #print(pygame.display.Info())
    Step = 2
    Size = 60
    offset = 0
    LastCamPos = 0
    miniOffset = 0
    while DEBUG.ISRUNNING:

        #thetaa += math.pi/512

        #Cam.v[2] -= DEBUG.JoystickAxis[3]/16

        phi += DEBUG.JoystickAxis[1] / 32

        vForward = vector([(-vLookDir.v[0]) * DEBUG.JoystickAxis[3] / 1,
                           (-vLookDir.v[1]) * DEBUG.JoystickAxis[3] / 1,
                           (-vLookDir.v[2]) * DEBUG.JoystickAxis[3] / 1])

        Cam += vForward

        #print(Cam)
        #vTarget = ([0,0,1])
        vLookDir = vector([0, math.sin(phi), math.cos(phi)])
        #vLookDir = vector([-math.sin(theta),0,math.cos(theta)])
        #vLookDir = vector([1,0,0])

        vTarget = Cam + vLookDir

        subMat = PointAt(Cam, vTarget, vUp)

        mtView = LookAtMatrix(subMat)

        #print(vTarget)
        sol = []

        #print(offset)

        if Cam.v[2] > Size + offset - 60:

            offset = int(Cam.v[2])
            miniOffset = Cam.v[2] - offset

        for i in range(-30, 30, Step):
            for j in range(offset, Size + offset, Step):

                sq1 = matrix.mat3x3([[i, 6, j - miniOffset],
                                     [i + Step, 6, j - miniOffset],
                                     [i, 6, j + Step - miniOffset]])

                sol.append(sq1)

        #Tst2 = sol.copy()
        #MatGraph.MultiplyMeshAndMatrix(Tst2,matrix.RotationMatrix("X",math.pi/2))
        #MatGraph.AddMeshAndMatrix(Tst2,matrix.mat3x3([[0,3,0],[0,3,0],[0,3,0]]))
        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Y",-thetaa))
        #MatGraph.AddMeshAndMatrix(Test,TranslationMatrix)
        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("X",thetaa))

        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("X",math.pi/6))
        #MatGraph.MultiplyMeshAndMatrix(Test,matrix.RotationMatrix("Z",math.pi/6))

        #FillMesh(Test,(255,255,255),Cam,Light,matView)
        #FillMesh(Tst2,(0,255,0),Cam,Light,matView)

        FillMesh(sol, (255, 255, 255), Cam, Light, mtView)

        #DrawMesh(Test,(255,255,255))

        DEBUG.HandleWindowEvents()

    DEBUG.quit()
Пример #27
0
    myApp.CIK = ''
    # <-- Exosite
    
    #Reboot system after <entered value> secs if unable to register with a network
    #Allow at least 5 minutes (300 seconds)
    MOD.watchdogEnable(300)

    try:
        RUN_MODE = 0
        test = float(RUN_MODE)  #float not implemented in Telit module
    except:
        #Running in IDE
        RUN_MODE = 1

    DEBUG.CLS(RUN_MODE)   #Clear screen command for VT100 terminals
    DEBUG.sendMsg("GPSDemo Script has started\r\n",RUN_MODE)  
  
    #Apply Network Specific settings see myApp.xxxx assignment above
    if (myApp.NETWORK == "ATT"):
        #Set module to work on US ATT Network  
        res = ATC.sendAtCmd("AT#ENS?",ATC.properties.CMD_TERMINATOR,3,2)        #query ENS setting
        if (res == "#ENS: 0"):
            res = ATC.sendAtCmd('AT#ENS=1',ATC.properties.CMD_TERMINATOR,3,2)   #sets all ATT requirements
            MOD.sleep(15)                                                       #required to halt Python thread and allow NVM Flash to update
            res = ATC.sendAtCmd('AT#REBOOT',ATC.properties.CMD_TERMINATOR,3,2)  #must reboot to take effect
        res = ATC.sendAtCmd("AT#SELINT?",ATC.properties.CMD_TERMINATOR,3,2)     #query SELINT setting
        if (res != "#SELINT: 2"):
            res = ATC.sendAtCmd('AT#SELINT=2',ATC.properties.CMD_TERMINATOR,3,2)#use of most recent AT command set
            MOD.sleep(15)                                                       #required to halt Python thread and allow NVM Flash to update
            res = ATC.sendAtCmd('AT#REBOOT',ATC.properties.CMD_TERMINATOR,3,2)  #must reboot to take effect
        
Пример #28
0
            album_dir = artist_dir + '/' + name[0:254]
        else:
            album_dir = artist_dir + '/' + name

        if not os.path.exists(album_dir):
           os.makedirs(album_dir)
        else:
           DEBUG.p('this album info exist!!!!')

def new_file(path):
    f = open(path, "w")
    f.close()

def func_test(b, a = 1):
    print a

def getDoc2(id):
    return dao.getById2(id)

def getDoc(artist, albumName):
    return dao.getById(artist, albumName)

if __name__ == '__main__':
    #make_dir()
    #new_file("xxoo")
    #result = getDoc('Fabulous Trobadors', 'Duels de tchatche')
    result = getDoc2('f639b7da9b1b1f5d4a463834a3da3b82')
    DEBUG.pd(result)


Пример #29
0
    def __saveAllInfos(self, jsonResultAlbum, country):
        #prepare dir
        dir_len = len(jsonResultAlbum['artistName'])
        if dir_len > 255:
            artist_dir = os.getcwd() + '/static/images/' + jsonResultAlbum['artistName'][0:200]
        else:
            artist_dir = os.getcwd() + '/static/images/' + jsonResultAlbum['artistName']
        dir_len = len(jsonResultAlbum['collectionName'])
        if dir_len > 255:
            album_dir = artist_dir + '/' + jsonResultAlbum['collectionName'][0:200]
        else:
            album_dir = artist_dir + '/' + jsonResultAlbum['collectionName']

        if not os.path.exists(artist_dir):
           os.makedirs(artist_dir)
        if not os.path.exists(album_dir):
           os.makedirs(album_dir)
        else:
           DEBUG.p('this album dir exist:%s'%(album_dir))
           result = dao.getById(jsonResultAlbum['artistName'], jsonResultAlbum['collectionName']) 
           DEBUG.pd(result)
           if result != None:
              DEBUG.p('this album info exist in db!!!!')
              return result 
           else:
              DEBUG.pw('this album info not exist in db!!!!')

        #result = dao.getById(jsonResultAlbum['artistName'], jsonResultAlbum['collectionName']) 
        #coverImage_1200 = jsonResultAlbum['artworkUrl100'].replace('100x100', '1200x1200').split('/')[-1]
        #if result != None and os.path.exists(album_dir + '/' + coverImage_1200):
        #   DEBUG.p('this album info exist in db!!!!')
        #   DEBUG.p('album:%s; artist:%s'%( jsonResultAlbum['collectionName'], jsonResultAlbum['artistName']))
        #   return result

        #save album info json file
        file = open(album_dir + "/album.json","w")
        json.dump(jsonResultAlbum, file)
        file.close()

        
        ##save album cover images
        ret = 0 
        coverImageUrl = jsonResultAlbum['artworkUrl100']
        ret += self.__saveCoverImage(album_dir, coverImageUrl)
        coverImageUrl_170 = coverImageUrl.replace('100x100', '170x170')
        ret += self.__saveCoverImage(album_dir, coverImageUrl_170)
        coverImageUrl_600 = coverImageUrl.replace('100x100', '600x600')
        ret += self.__saveCoverImage(album_dir, coverImageUrl_600)
        coverImageUrl_1200 = coverImageUrl.replace('100x100', '1200x1200')
        ret += self.__saveCoverImage(album_dir, coverImageUrl_1200)
        if ret == 0:
           return ret 

        info = {
                'album_name': '',
                'artist': '',
                'year_record': '12345',
                'music_contain': 'Nothing',
                'path': u'static/images/',
                'cover_name_1200': u'onePiece.png',
                'cover_name_170': u'onePiece.png',
                'cover_name_100': u'onePiece.png',
                'copy_right': u'lewis',
                'track_count': 1,
                'width': 0,
                'height': 0,
                'size': 0,
                'format': 'jpeg',
                'des':'come on boy!!! day day up!!!',
                'itunes_album_url': '',
                'itunes_artist_url': ''
        }
        #DEBUG.pd(jsonResultAlbum)
        info['path'] = album_dir + '/'
        info['cover_name_1200'] = coverImageUrl_1200.split('/')[-1] 
        info['cover_name_170'] = coverImageUrl_170.split('/')[-1] 
        info['cover_name_100'] = coverImageUrl.split('/')[-1] 
        info['album_name'] = jsonResultAlbum['collectionName'] 
        info['artist'] = jsonResultAlbum['artistName'] 
        info['cover_name'] = coverImageUrl_1200.split('/')[-1] 
        info['year_record'] = jsonResultAlbum['releaseDate']
        info['track_count'] = jsonResultAlbum['trackCount']
        info['itunes_album_url'] = jsonResultAlbum['collectionViewUrl']
        if jsonResultAlbum.has_key('artistViewUrl'): 
           info['itunes_artist_url'] = jsonResultAlbum['artistViewUrl']
        if jsonResultAlbum.has_key('copyright'): 
           info['copy_right'] = jsonResultAlbum['copyright']

        musicContains = []
        jsonMusics = []
        jsonResultMusics = self.__getMusicLists(jsonResultAlbum['collectionName'], country)
        if len(jsonResultMusics) == jsonResultAlbum['trackCount']: 
           for jsonResultMusic in jsonResultMusics:
               musicContains.append(jsonResultMusic['trackName'])
           jsonMusics = jsonResultMusics
        else:
           for jsonResultMusic in jsonResultMusics:
               if jsonResultMusic['artistName'] == jsonResultAlbum['artistName']:
                  musicContains.append(jsonResultMusic['trackName'])
                  jsonMusics.append(jsonResultMusic)
        try:
            if len(jsonMusics) == 0:
               for jsonResultMusic in jsonResultMusics:
                   if jsonResultMusic['collectionId'] == jsonResultAlbum['collectionId']:
                      musicContains.append(jsonResultMusic['trackName'])
                      jsonMusics.append(jsonResultMusic)
        except:
            DEBUG.p("empty music list!!!")

        #save music list json file
        file = open(album_dir + "/album_musics.json","w")
        json.dump(jsonMusics, file)
        file.close()

        info['music_contain'] = list(set(musicContains)) 
        DEBUG.pd(info)

        try:
            #record info into db
            dao.addOneDoc(info)
        except:
            print 'add doc failed: %s:%s'%(info['artist'], info['album_name'])
            print traceback.print_exc()
            

        return info
Пример #30
0
def sendEMAIL(theEmailToAddress,theEmailSubject,theEmailBody,theTerminator,userID,userPassword,retry,timeOut):
#This function sends email

  # Input Parameter Definitions
  #   theEmailSubject: The text Email Subject
  #   theEmailBody: The text Email Body
  #   theTerminator: string or character at the end of AT Command
  #   retry:  How many times the command will attempt to retry if not successfully send 
  #   timeOut: number of [1/10 seconds] command could take to respond

    try:

        tmpReturn = -1
            
        while (retry != -1):

            #Activate PDP if needed  
            res = sendAtCmd('AT#SGACT?',properties.CMD_TERMINATOR,0,20) 
            if (res!="#SGACT: 1,1"):
                delaySec(1)
                res = sendAtCmd('AT#SGACT=1,1,"' + str(userID) + '","' + str(userPassword) + '"' ,properties.CMD_TERMINATOR,0,180)
                DEBUG.sendMsg(res + '\r\n',RUN_MODE) 

            if (res=='ERROR'):
                return tmpReturn  

            print 'AT#EMAILD="' + theEmailToAddress + '","' + theEmailSubject + '",0'

            res = MDM.send('AT#EMAILD="' + theEmailToAddress + '","' + theEmailSubject + '",0', 0)
            res = MDM.sendbyte(0x0d, 0)
            res = mdmResponse('\r\n>', timeOut)
            print res 

            res = MDM.send(theEmailBody, 0)
            res = MDM.sendbyte(0x1a, 0)

            #Start timeout counter        
            timerA = timers.timer(0)
            timerA.start(timeOut)

            #Wait for response
            res = ''
            while ((res.find(theTerminator)<=-1) and (res.find("ERROR")<=-1) and (res != 'timeOut')):
                MOD.watchdogReset()
                res = res + MDM.receive(10)
                pass           
                if timerA.isexpired():
                    res = 'timeOut'
                    
            if((res.find("ERROR") > -1) or (res == 'timeOut')):
                retry = retry - 1
            else:
                retry = -1
                tmpReturn = 0                
                
    except:
        print 'Script encountered an exception.'
        print 'Exception Type: ' + str(sys.exc_type)
        print 'MODULE -> ATC'
        print 'METHOD -> sendEMAIL(' + theEmailToAddress + ',' + theEmailSubject + ',' + theEmailBody + ',' +theTerminator + ',' + retry + ',' + timeOut + ')'

    print res
  
    return tmpReturn
Пример #31
0
    def __saveAllInfos(self, jsonResultAlbum, country):
        #prepare dir
        dir_len = len(jsonResultAlbum['artistName'])
        if dir_len > 255:
            artist_dir = os.getcwd(
            ) + '/static/images/' + jsonResultAlbum['artistName'][0:200]
        else:
            artist_dir = os.getcwd(
            ) + '/static/images/' + jsonResultAlbum['artistName']
        dir_len = len(jsonResultAlbum['collectionName'])
        if dir_len > 255:
            album_dir = artist_dir + '/' + jsonResultAlbum['collectionName'][
                0:200]
        else:
            album_dir = artist_dir + '/' + jsonResultAlbum['collectionName']

        if not os.path.exists(artist_dir):
            os.makedirs(artist_dir)
        if not os.path.exists(album_dir):
            os.makedirs(album_dir)
        else:
            DEBUG.p('this album dir exist:%s' % (album_dir))
            result = dao.getById(jsonResultAlbum['artistName'],
                                 jsonResultAlbum['collectionName'])
            DEBUG.pd(result)
            if result != None:
                DEBUG.p('this album info exist in db!!!!')
                return result
            else:
                DEBUG.pw('this album info not exist in db!!!!')

        #result = dao.getById(jsonResultAlbum['artistName'], jsonResultAlbum['collectionName'])
        #coverImage_1200 = jsonResultAlbum['artworkUrl100'].replace('100x100', '1200x1200').split('/')[-1]
        #if result != None and os.path.exists(album_dir + '/' + coverImage_1200):
        #   DEBUG.p('this album info exist in db!!!!')
        #   DEBUG.p('album:%s; artist:%s'%( jsonResultAlbum['collectionName'], jsonResultAlbum['artistName']))
        #   return result

        #save album info json file
        file = open(album_dir + "/album.json", "w")
        json.dump(jsonResultAlbum, file)
        file.close()

        ##save album cover images
        ret = 0
        coverImageUrl = jsonResultAlbum['artworkUrl100']
        ret += self.__saveCoverImage(album_dir, coverImageUrl)
        coverImageUrl_170 = coverImageUrl.replace('100x100', '170x170')
        ret += self.__saveCoverImage(album_dir, coverImageUrl_170)
        coverImageUrl_600 = coverImageUrl.replace('100x100', '600x600')
        ret += self.__saveCoverImage(album_dir, coverImageUrl_600)
        coverImageUrl_1200 = coverImageUrl.replace('100x100', '1200x1200')
        ret += self.__saveCoverImage(album_dir, coverImageUrl_1200)
        if ret == 0:
            return ret

        info = {
            'album_name': '',
            'artist': '',
            'year_record': '12345',
            'music_contain': 'Nothing',
            'path': u'static/images/',
            'cover_name_1200': u'onePiece.png',
            'cover_name_170': u'onePiece.png',
            'cover_name_100': u'onePiece.png',
            'copy_right': u'lewis',
            'track_count': 1,
            'width': 0,
            'height': 0,
            'size': 0,
            'format': 'jpeg',
            'des': 'come on boy!!! day day up!!!',
            'itunes_album_url': '',
            'itunes_artist_url': ''
        }
        #DEBUG.pd(jsonResultAlbum)
        info['path'] = album_dir + '/'
        info['cover_name_1200'] = coverImageUrl_1200.split('/')[-1]
        info['cover_name_170'] = coverImageUrl_170.split('/')[-1]
        info['cover_name_100'] = coverImageUrl.split('/')[-1]
        info['album_name'] = jsonResultAlbum['collectionName']
        info['artist'] = jsonResultAlbum['artistName']
        info['cover_name'] = coverImageUrl_1200.split('/')[-1]
        info['year_record'] = jsonResultAlbum['releaseDate']
        info['track_count'] = jsonResultAlbum['trackCount']
        info['itunes_album_url'] = jsonResultAlbum['collectionViewUrl']
        if jsonResultAlbum.has_key('artistViewUrl'):
            info['itunes_artist_url'] = jsonResultAlbum['artistViewUrl']
        if jsonResultAlbum.has_key('copyright'):
            info['copy_right'] = jsonResultAlbum['copyright']

        musicContains = []
        jsonMusics = []
        jsonResultMusics = self.__getMusicLists(
            jsonResultAlbum['collectionName'], country)
        if len(jsonResultMusics) == jsonResultAlbum['trackCount']:
            for jsonResultMusic in jsonResultMusics:
                musicContains.append(jsonResultMusic['trackName'])
            jsonMusics = jsonResultMusics
        else:
            for jsonResultMusic in jsonResultMusics:
                if jsonResultMusic['artistName'] == jsonResultAlbum[
                        'artistName']:
                    musicContains.append(jsonResultMusic['trackName'])
                    jsonMusics.append(jsonResultMusic)
        try:
            if len(jsonMusics) == 0:
                for jsonResultMusic in jsonResultMusics:
                    if jsonResultMusic['collectionId'] == jsonResultAlbum[
                            'collectionId']:
                        musicContains.append(jsonResultMusic['trackName'])
                        jsonMusics.append(jsonResultMusic)
        except:
            DEBUG.p("empty music list!!!")

        #save music list json file
        file = open(album_dir + "/album_musics.json", "w")
        json.dump(jsonMusics, file)
        file.close()

        info['music_contain'] = list(set(musicContains))
        DEBUG.pd(info)

        try:
            #record info into db
            dao.addOneDoc(info)
        except:
            print 'add doc failed: %s:%s' % (info['artist'],
                                             info['album_name'])
            print traceback.print_exc()

        return info
Пример #32
0
    #print(offset)

    if Cam.v[2] > Size + offset - 60:

        offset = int(Cam.v[2])
        miniOffset = Cam.v[2] - offset

    for i in range(-30, 30, Step):
        for j in range(offset, Size + offset, Step):

            sq1 = matrix.mat3x3([[i, 6, j - miniOffset],
                                 [i + Step, 6, j - miniOffset],
                                 [i, 6, j + Step - miniOffset]])

            sol.append(sq1)
    print()

    FillMesh(sol, (255, 255, 255), Cam, Light, mtView)


if __name__ == "__main__":
    import DEBUG
    Init()
    while DEBUG.ISRUNNING:

        Affichage(0, 0, 0)

        DEBUG.HandleWindowEvents()

    pygame.quit()
Пример #33
0
 def __saveCoverImage(self, album_dir, coverImageUrl):
     try:
         #f = urllib2.urlopen(coverImageUrl)
         #with open(album_dir + '/' + coverImageUrl.split('/')[-1], 'wb') as code:
         #    code.write(f.read())
         data = urllib2.urlopen(coverImageUrl, data=None, timeout=20).read()
         DEBUG.p('got data:') 
         f = open(album_dir + '/' + coverImageUrl.split('/')[-1], 'wb')
         f.write(data)
         DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1])) 
         f.close()
         return 1 
     except:
         DEBUG.p('%s Pic Saved failed! and try again...' % (coverImageUrl.split('/')[-1])) 
         try:
             data = urllib2.urlopen(coverImageUrl, data=None, timeout=40).read()
             DEBUG.p('got data:') 
             f = open(album_dir + '/' + coverImageUrl.split('/')[-1], 'wb')
             f.write(data)
             DEBUG.p('%s Pic Saved!' % (coverImageUrl.split('/')[-1])) 
             f.close()
             return 1 
         except:
             DEBUG.p('err: %s Pic Saved failed!' % (coverImageUrl.split('/')[-1])) 
             #remove failed-file
             if os.path.exists(album_dir + '/' + coverImageUrl.split('/')[-1]):
                 os.remove(album_dir + '/' + coverImageUrl.split('/')[-1])
             f = open(album_dir + '/' + coverImageUrl.split('/')[-1] + ".failed", "w")
             f.close()
             #save music url into json file
             file = open(os.getcwd() + '/static/failed_url',"ab")
             json.dump((coverImageUrl,album_dir), file)
             file.close()
             return 0 
Пример #34
0
def Init():
    DEBUG.init()
    Graphics.initDisplayHandler(DEBUG.window, DEBUG.ScreenSize, 100,
                                15 * math.pi / 180)
Пример #35
0
    if not os.path.exists(album_dir):
        os.makedirs(album_dir)
    else:
        DEBUG.p('this album info exist!!!!')


def new_file(path):
    f = open(path, "w")
    f.close()


def func_test(b, a=1):
    print a


def getDoc2(id):
    return dao.getById2(id)


def getDoc(artist, albumName):
    return dao.getById(artist, albumName)


if __name__ == '__main__':
    #make_dir()
    #new_file("xxoo")
    #result = getDoc('Fabulous Trobadors', 'Duels de tchatche')
    result = getDoc2('f639b7da9b1b1f5d4a463834a3da3b82')
    DEBUG.pd(result)