def _check_files_format(*args, **kwargs): mainController = Controller() configFound, wrongFiles = mainController.check_files_format() if not configFound: sys_print(u'检测到你不在印象笔记主目录中,或配置文件损坏', 'warn') elif mainController.available: if wrongFiles and not DEBUG: for fileName, status in wrongFiles: if status == 1: sys_print(u'检测到错误放置的内容:' + fileName.decode('utf8'), 'warn') elif status == 2: sys_print(u'检测到内容过大的文件:' + fileName.decode('utf8'), 'warn') elif status == 3: sys_print(u'检测到意义不明的文件:' + fileName.decode('utf8'), 'warn') sys_print(u'请确保单条笔记有md或html的正文且不大于%s字节' % mainController.ls.maxUpload) sys_print(u'请确保没有文件夹格式的附件,或名为.DS_Store的笔记及笔记本。') else: return fn(mainController, *args, **kwargs) elif mainController.ls.get_credential(): u, p = mainController.ls.get_credential().split('|') _, _, sandbox, is_international, expire_time, _, _ = mainController.ls.get_config( ) token = TokenFetcher(is_international, u, p).fetch_token() if token: mainController.log_in(token=token, isSpecialToken=True, sandbox=sandbox, isInternational=is_international, expireTime=expire_time) if mainController.available: mainController.ls.update_config( token=token, isSpecialToken=True, sandbox=sandbox, isInternational=is_international, expireTime=expire_time) sys_print(u'刷新token成功') return fn(mainController, *args, **kwargs) else: sys_print(u'刷新token失败') else: sys_print(u'获取token失败,请检查用户名密码') else: sys_print(u'尚未初始化', 'warn')
def _check_files_format(*args, **kwargs): mainController = Controller() configFound, wrongFiles = mainController.check_files_format() if not configFound: sys_print(u'检测到你不在印象笔记主目录中,或配置文件损坏', 'warn') elif mainController.available: if wrongFiles: for fileName, status in wrongFiles: if status == 1: sys_print(u'检测到错误放置的内容:'+fileName.decode('utf8'), 'warn') elif status == 2: sys_print(u'检测到内容过大的文件:'+fileName.decode('utf8'), 'warn') elif status == 3: sys_print(u'检测到意义不明的文件:'+fileName.decode('utf8'), 'warn') sys_print(u'请确保单条笔记有md或html的正文且不大于%s字节,笔记中没有文件夹格式的附件。'%mainController.ls.maxUpload, 'info') else: return fn(mainController, *args, **kwargs) else: sys_print(u'尚未登录', 'warn')