作者 lemon

增加返回错误信息完整信息

... ... @@ -13,6 +13,8 @@ from lib import common
import uuid
from base64 import b64decode
from lib.common import WorkPlace
def _send_msg(local_func, remote_func, to, content, thread_type, suffix):
_type = getattr(ThreadType, thread_type.upper())
... ... @@ -160,3 +162,10 @@ class Executor():
info['gender'] = 'boy' if info['gender'] == 'male_singular' else 'girl'
objects.append(info)
return objects
def addWork(self, work_detail, privacy='EVERYONE'):
print(work_detail)
work = WorkPlace.from_dict(work_detail)
print(work)
res = self.client.addWorkPlace(work, privacy)
return res
... ...
... ... @@ -8,6 +8,7 @@ import functools
import logging
import threading
import time
import traceback
import uuid
from concurrent.futures import ThreadPoolExecutor
from threading import Timer
... ... @@ -165,7 +166,8 @@ class Monitor(callback.CallBack):
try:
res = func(**kwargs)
except BaseException as err:
self._task_(func.__name__, client, taskid, code=TaskStatus.EXCEPTION, msg={'error': repr(err)})
self._task_(func.__name__, client, taskid, code=TaskStatus.FAILED,
msg={'error': repr(err), 'full_error': traceback.format_exc()})
else:
self._task_(func.__name__, client, taskid, code=TaskStatus.SUCCESS, msg=res)
... ... @@ -187,6 +189,7 @@ class Monitor(callback.CallBack):
else:
try:
client = self._get_member(target)
assert hasattr(client, 'extend'), '帐号未登录'
if hasattr(client.extend, type_):
func = getattr(client.extend, type_)
else:
... ... @@ -195,4 +198,4 @@ class Monitor(callback.CallBack):
kwargs = parameter.join(func, payload)
self.executor.submit(self.thread, client, taskid, kwargs)
except BaseException as err:
self._socket.send({'error': repr(err)})
self._task_(type_, Munch(email=target), taskid, code=TaskStatus.EXCEPTION, msg={'error': repr(err)})
... ...
... ... @@ -46,13 +46,29 @@ class WorkPlace():
return data
@classmethod
def from_dict(cls,data:dict):
def from_dict(cls, data: dict):
self = cls()
for k,v in data.items():
if hasattr(self,k):
setattr(self,k,v)
return self
for k, v in data.items():
if hasattr(self, k):
setattr(self, k, v)
start_time = []
end_time = []
for x in ['year', 'month', 'day']:
if data.get(f'date_start[{x}]'):
start_time.append(int(data.get(f'date_start[{x}]')))
if data.get(f'date_end[{x}]'):
end_time.append(int(data.get(f'date_end[{x}]')))
if start_time:
self.start_time = datetime.date(*start_time)
if end_time:
self.end_time = datetime.date(*end_time)
else:
self.current = True
return self
@attrs(cmp=False)
... ...
... ... @@ -312,19 +312,29 @@ class FacebookClient(Client):
return {"success": True}
return res
def addWorkPlace(self, workplace: WorkPlace):
def addWorkPlace(self, workplace: WorkPlace, value='EVERYONE'):
'''添加工作经历'''
value = PostParam.__dict__.get(value).value
data = {
# 'hub_id': '142351455848493',
'type': '2002',
'ref': 'about_tab',
'action_type': 'add', # add | edit
'experience_id': '0',
'privacy[741155019280009]': PostParam.EVERYONE.value
'privacy[741155019280009]': value
}
data.update(workplace.to_dict())
res = self._post('/profile/edit/work/save/', data)
return res
try:
return {
'success': True,
'setting': res['jsmods']['require'][1][3][0]['props']
}
except:
return {
'success': False,
'error': res['jsmods']['require']
}
def addCollege(self, college: College):
'''添加教育记录'''
... ...