1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import handleManager
- import tkinter
- from tkinter import filedialog
- from webdav3.client import Client # 使用pip install webdavclient3 安装
- # 加载后
- def after_load(event):
- return True
- # 卸载前
- def before_unload(event):
- return True
- # 判断流程能否处理
- def support(event):
- return True
- webdav_connection_options__jianguo = {
- 'webdav_hostname': "https://dav.jianguoyun.com/dav/",
- 'webdav_login': "cn_lym@foxmail.com",
- 'webdav_password': "atj4hxt8rdeh79aj",
- 'disable_check': True, # 有的网盘不支持check功能
- }
- # todo 连接放全局上下文
- client = Client(webdav_connection_options__jianguo)
- upload_target_dir = 'spider_cloud/'
- def upload(file_path, file_name='____file__name'):
- if file_name == '____file__name':
- file_name = file_path.split('/')[-1] # 获取要上传的文件名
- # 第一个参数为webdav中的路径,可自定义
- client.upload(upload_target_dir + file_name, file_path)
- # 注:若webdav中已经有同名称文件则会进行覆盖
- return upload_target_dir + file_name
- 'oss-cn-hongkong.aliyuncs.com'
- def handle(faas__request_wrap):
- # 取出参数和输入上下文
- params = faas__request_wrap[handleManager.const_key_params]
- context = faas__request_wrap[handleManager.const_key_context]
- # 拿到任务,调用异步执行,后置操作放结果到 mq
- if not params['task']:
- raise RuntimeError('no task define')
- task = params['task']
- headers = task['headers']
- result = {
- 'process_result': {
- 'spider': context
- },
- 'content': content,
- 'next-command': next_command
- }
- return content
|