def main(): parser = OptionParser() parser.add_option("-a", "--address", dest="host", action="store", default=socket.gethostname(), type="str", help="the address or host name on which the server is listening") parser.add_option("-p", "--request_port", action="store", dest="request_port", default=5005, type="int", help="the port number on which the server is listening for tcp requests.") parser.add_option("-w", "--workspace", action="store", dest="workspace", default='../config/', type="str", help="the server workspace location.") parser.add_option("-b", "--broadcast_port", action="store", dest="broadcast_port", default='5555', type="int", help="the port on which the server is broadcasting it's presence.") options, args = parser.parse_args() HOST = options.host PORT = options.request_port TARGET_PORT = options.broadcast_port WORKSPACE = options.workspace config.setWorkspaceLocation(WORKSPACE) server = assembleServer(HOST, PORT, TARGET_PORT) try: server.start() except KeyboardInterrupt: print "The server received a keypress event. Stopping the server." except Exception as ex: print "The server encountered an unexpected exception: {0}".format(ex) finally: server.stop()
for track in tracks: print track dirname = os.path.dirname(track.filePath) coverFullname = dirname + "/" + "cover.jpg" _file = File(track.filePath) # mutagen can automatically detect format and type of tags artwork = None try: artwork = _file.tags['APIC:'].data # access APIC frame and grab the image except KeyError as e: pass if not artwork: try: if track.filePath.endswith(".flac"): _file = FLAC(track.filePath) if len(_file.pictures) > 0: artwork = _file.pictures[0].data except KeyError as e: pass if artwork: if not os.path.isfile(coverFullname): print "will write {0}".format(coverFullname) with open(coverFullname, 'wb') as f: f.write(artwork) # write artwork to new image if __name__ == '__main__': import config config.setWorkspaceLocation('/media/dat/app/yam/workspace') indexArtistsWithRandomCover() indexAlbums()
def _workspaceValueChanged(self, sender): workspace = self.directoryEdit.text() print "Setting workspace location:", workspace config.setWorkspaceLocation(workspace)