| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | import osimport timeimport datetimefiles = []class FileUtil:    dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))    save_path = r'{}/elab_mvp/resources/report_jian'.format(dir_path)    def save_path_create(self):        tm = datetime.datetime.now().strftime('%Y-%m-%d')        new_path = '{}/{}'.format(self.save_path, tm)        FileUtil.mkdir_folder(new_path)        return new_path    @staticmethod    def mkdir_folder(path):        if os.path.exists(path):            print('folder exists')            pass        else:            print('create folder')            os.mkdir(path)    @staticmethod    def load_file(path):        for file in os.listdir(path):            file_path = os.path.join(path, file)            if os.path.isdir(file_path):                FileUtil.load_file(file_path)            else:                files.append(file_path)        return files    @staticmethod    def remove_files(breday, path):        bretime = time.time() - 3600 * 24 * breday        for file in FileUtil.load_file(path):            filename = file            if os.path.getmtime(filename) < bretime:                try:                    if os.path.isfile(filename):                        os.remove(filename)                    elif os.path.isdir(filename):                        os.removedirs(filename)                    else:                        os.remove(filename)                    print("%s remove success." % filename)                except Exception as error:                    print(error)                    print("%s remove faild." % filename)if __name__ == '__main__':    file_path = r'D:\elab-code\elab-layout-engine\resources\house_type\house_dxf_files'
 |