def stage_rdiff_backup_repos(self, repos_path, time='now'): staging_path = '%s-staging' % repos_path makepaths(staging_path) restore_cmd = 'rdiff-backup --force -r %s %s %s' % (time, repos_path, staging_path) result = os.system(restore_cmd) if result: raise OSError, "there was a problem with %s" % restore_cmd return staging_path
def _generate_archive_directories(self): cfg = self.myconfig installed_archives_path = cfg.get('filemanagement', 'installed_archives_path') extras_archives_path = cfg.get('filemanagement', 'extras_archives_path') makepaths(installed_archives_path, extras_archives_path) self.installed_archives_path = installed_archives_path self.extras_archives_path = extras_archives_path self.main_dosbox_path = cfg.get('dosbox', 'main_dosbox_path')
def _generate_archive_directories(self): cfg = self.myconfig installed_archives_path = cfg.getpath("filemanagement", "installed_archives_path") extras_archives_path = cfg.getpath("filemanagement", "extras_archives_path") makepaths(installed_archives_path, extras_archives_path) self.installed_archives_path = installed_archives_path self.extras_archives_path = extras_archives_path self.main_dosbox_path = cfg.getpath("dosbox", "main_dosbox_path")
def unzip_file(filename, path): if not os.path.exists(path): makepaths(path) if not os.path.isdir(path): raise StandardError, "%s already exists and is not a directory." % path #zfile = ZipFile(filename, 'r') zfile = MyZipFile(filename, 'r') zfile.extract(path=path)
def stage_rdiff_backup_repos(self, repos_path, time='now'): staging_path = '%s-staging' % repos_path makepaths(staging_path) restore_cmd = 'rdiff-backup --force -r %s %s %s' % (time, repos_path, staging_path) args = ['rdiff-backup', '--force', '-r', str(time), repos_path, staging_path] result = subprocess.call(args) if result: raise OSError, "there was a problem with %s" % ' '.join(args) return staging_path
def prepare_game(self, name, time='now', extras=True): fullpath = self._get_fullpath(name) if os.path.exists(fullpath): _checkifdir(fullpath) else: makepaths(fullpath) zfilename = self.archivehelper.determine_install_zipfilename(name=name) if not os.path.exists(zfilename): raise ExistsError, "%s for %s doesn't exist." % (zfilename, name) zfile = MyZipFile(zfilename, 'r') zfile.extract(path=fullpath, report=self._report_extract_from_installed_archive) if extras: self.restore_extra_files(name, time=time)
def __init__(self, app): self.app = app self.main_config_dir = self.app.main_config_dir self.profiles_dir = os.path.join(self.main_config_dir, 'profiles') self.default_config = os.path.join(self.main_config_dir, 'dosbox.conf.default') self.tmp_parent_path = os.path.join(self.app.tmpdir, 'dosbox-area') if not os.path.isdir(self.tmp_parent_path): makepaths(self.tmp_parent_path) self._dosbox_binary = self.app.myconfig.get('dosbox', 'dosbox_binary') self.current_profile = None profiles = self.get_profile_list() if not profiles or 'default' not in profiles: print 'creating default profile' cfg = self.get_default_config() self.save_profile('default', cfg) self.set_current_profile('default')
def __init__(self, app): self.app = app self.main_config_dir = self.app.main_config_dir self.profiles_dir = os.path.join(self.main_config_dir, "profiles") self.default_config = os.path.join(self.main_config_dir, "dosbox.conf.default") self.tmp_parent_path = os.path.join(self.app.tmpdir, "dosbox-area") if not os.path.isdir(self.tmp_parent_path): makepaths(self.tmp_parent_path) self._dosbox_binary = self.app.myconfig.get("dosbox", "dosbox_binary") self.current_profile = None profiles = self.get_profile_list() if not profiles or "default" not in profiles: print "creating default profile" cfg = self.get_default_config() self.save_profile("default", cfg) self.set_current_profile("default")
def cleanup_unchanged_files(self, path, unchanged_files, remove=True): _checkifdir(path) here = os.getcwd() if not remove: newpath = self._unchanged_files_holding_path(path) makepaths(newpath) os.chdir(path) if remove: map(os.remove, unchanged_files) else: print "remove is false, moving files to", newpath for afile in unchanged_files: dirname, basename = os.path.split(afile) newdir = os.path.join(newpath, dirname) makepaths(newdir) newfile = os.path.join(newdir, basename) # clean up the path name newfile = os.path.normpath(newfile) os.rename(afile, newfile) print os.listdir(newpath) os.chdir(here)
def generate_configuration(self, name): config = DosboxConfig() # order is default then game-specific # game-specific overrides default cfiles = [self.default_config] if self.current_profile is not None: cfiles.append(self._get_profile_configfilename(self.current_profile)) cfiles.append(self._game_specific_configfilename(name)) config.read(cfiles) # setup capture directory path = self.get_capture_path(name) if not os.path.exists(path): makepaths(path) config.set('dosbox', 'captures', path) mapperfile = self._mapper_filename(name) if os.path.exists(mapperfile): config.set('sdl', 'mapperfile', mapperfile) configfilename = self._configfilename(name) dirname = os.path.dirname(configfilename) if not os.path.exists(dirname): makepaths(dirname) config.write(file(configfilename, 'w'))
def extract(self, name=None, path=None, report=None): if path is None: path = os.getcwd() if not os.path.isdir(path): raise IOError, 'directory %s not found.' % path if name is None: namelist = self.namelist() total = len(namelist) count = 1 for filename in namelist: if report is not None: report(filename, count, total) dirname = os.path.dirname(filename) if dirname: complete_dirname = os.path.join(path, dirname) makepaths(complete_dirname) basename = os.path.basename(filename) if basename: self._extract_file(filename, path) count += 1 else: self._extract_file(name, path)
def make_tmp_path(self, name): tpath = os.path.join(self.app.tmpdir, name) makepaths(tpath) return tpath
def unzip_file(filename, path): if not os.path.exists(path): makepaths(path) if not os.path.isdir(path): raise StandardError, "%s already exists and is not a directory." % path #zfile = ZipFile(filename, 'r') zfile = MyZipFile(filename, 'r') zfile.extract(path=path) def extract_report(filename, count, total): print 'extracting', filename, count, total def archive_report(filename, count, total): print 'archiving', filename, count, total if __name__ == '__main__': zipfilename = sys.argv[1] path = sys.argv[2] #unzip_file(zipfilename, path) makepaths(path) mf = MyZipFile(zipfilename, 'r') mf.extract(path=path, report=extract_report) empty_dirs = [os.path.join(path, adir) for adir in ['heythere', 'hello', 'something/else']] #makepaths(*empty_dirs) mf = MyZipFile('anewfile.zip', 'w') mf.archive_path(path, report=archive_report) mf.close()