if not force: game = db.load_game_by_key(source, id, ignore_empty=False) if game: print 'up-to-date %s/%d...' % (source, int(id)) return game else: print 'force', print 'updating %s/%d...' % (source, int(id)), sys.stdout.flush() if sleep_between_downloads: print 'sleeping %s sec...' % sleep_between_downloads, sys.stdout.flush() time.sleep(sleep_between_downloads) game = parse_game(source, id) if game: print 'found:"' + game.name + '"...', db.save_game(game) else: print 'no game found...', g = Game() g.source = source g.id = id db.save_game(g) print 'OK' return game entrypoint(update)
# downloader = DownloaderFactory.createDownloader(not nocache) # def game_downloader(game, targetDir, downloader): # gameUrl = game.game_file_url # game.zip = downloader.downloadFile(gameUrl, targetDir, # downloadOptions=downloadOptions) # if src_plugin.game_downloader: # game_downloader = src_plugin.game_downloader # game_downloader(game, targetDir, downloader) db.save_game(game) def unpack_game(game, removezip=False): targetDir = config.GAMES / game.source / convertToFileName( game.name) + '.' + str(game.id) print 'unpacking %s...' % game.name, sys.stdout.flush() pyunpack.Archive(game.zip).extractall(targetDir, auto_create_dir=True) # if msg: # return False print 'OK' if removezip: os.remove(game.zip) game.dir = targetDir db.save_game(game) return True entrypoint(install_game)
# def game_downloader(game, targetDir, downloader): # gameUrl = game.game_file_url # game.zip = downloader.downloadFile(gameUrl, targetDir, # downloadOptions=downloadOptions) # if src_plugin.game_downloader: # game_downloader = src_plugin.game_downloader # game_downloader(game, targetDir, downloader) db.save_game(game) def unpack_game(game, removezip=False): targetDir = config.GAMES / game.source / convertToFileName( game.name) + '.' + str(game.id) print 'unpacking %s...' % game.name, sys.stdout.flush() pyunpack.Archive(game.zip).extractall(targetDir, auto_create_dir=True) # if msg: # return False print 'OK' if removezip: os.remove(game.zip) game.dir = targetDir db.save_game(game) return True entrypoint(install_game)