def checkAdminPath(): for path in DefaultPath.__ADMIN_CREATED__: if not DiskUtils.is_dir_exist(path): MsgUtils.warning("%r needed, creating" % path) if DiskUtils.create_path(path) == False: MsgUtils.error("can't create %r" % path) sys.exit(1) return True
def pushLogs(filename, maxLogFile): adir, basefile = os.path.split(filename) if not DiskUtils.is_dir_exist(adir): if not DiskUtils.create_path(adir): MsgUtils.error("Cannot create dir %r" % adir) sys.exit(1) if not os.path.exists(filename): return filename for i in range(maxLogFile, 0, -1): tofile = os.path.join(adir, "%s.%d" % (basefile, i + 1)) fromfile = os.path.join(adir, "%s.%d" % (basefile, i)) if os.path.exists(tofile) and os.path.exists(fromfile): DiskUtils.remove_file(tofile) if os.path.exists(fromfile): DiskUtils.rename_file(fromfile, tofile) DiskUtils.rename_file( os.path.join(adir, basefile), os.path.join(adir, '%s.1' % basefile)) return os.path.join(adir, basefile)