正在显示
4 个修改的文件
包含
48 行增加
和
10 行删除
| @@ -13,6 +13,8 @@ from lib import common | @@ -13,6 +13,8 @@ from lib import common | ||
| 13 | import uuid | 13 | import uuid |
| 14 | from base64 import b64decode | 14 | from base64 import b64decode |
| 15 | 15 | ||
| 16 | +from lib.common import WorkPlace | ||
| 17 | + | ||
| 16 | 18 | ||
| 17 | def _send_msg(local_func, remote_func, to, content, thread_type, suffix): | 19 | def _send_msg(local_func, remote_func, to, content, thread_type, suffix): |
| 18 | _type = getattr(ThreadType, thread_type.upper()) | 20 | _type = getattr(ThreadType, thread_type.upper()) |
| @@ -160,3 +162,10 @@ class Executor(): | @@ -160,3 +162,10 @@ class Executor(): | ||
| 160 | info['gender'] = 'boy' if info['gender'] == 'male_singular' else 'girl' | 162 | info['gender'] = 'boy' if info['gender'] == 'male_singular' else 'girl' |
| 161 | objects.append(info) | 163 | objects.append(info) |
| 162 | return objects | 164 | return objects |
| 165 | + | ||
| 166 | + def addWork(self, work_detail, privacy='EVERYONE'): | ||
| 167 | + print(work_detail) | ||
| 168 | + work = WorkPlace.from_dict(work_detail) | ||
| 169 | + print(work) | ||
| 170 | + res = self.client.addWorkPlace(work, privacy) | ||
| 171 | + return res |
| @@ -8,6 +8,7 @@ import functools | @@ -8,6 +8,7 @@ import functools | ||
| 8 | import logging | 8 | import logging |
| 9 | import threading | 9 | import threading |
| 10 | import time | 10 | import time |
| 11 | +import traceback | ||
| 11 | import uuid | 12 | import uuid |
| 12 | from concurrent.futures import ThreadPoolExecutor | 13 | from concurrent.futures import ThreadPoolExecutor |
| 13 | from threading import Timer | 14 | from threading import Timer |
| @@ -165,7 +166,8 @@ class Monitor(callback.CallBack): | @@ -165,7 +166,8 @@ class Monitor(callback.CallBack): | ||
| 165 | try: | 166 | try: |
| 166 | res = func(**kwargs) | 167 | res = func(**kwargs) |
| 167 | except BaseException as err: | 168 | except BaseException as err: |
| 168 | - self._task_(func.__name__, client, taskid, code=TaskStatus.EXCEPTION, msg={'error': repr(err)}) | 169 | + self._task_(func.__name__, client, taskid, code=TaskStatus.FAILED, |
| 170 | + msg={'error': repr(err), 'full_error': traceback.format_exc()}) | ||
| 169 | else: | 171 | else: |
| 170 | self._task_(func.__name__, client, taskid, code=TaskStatus.SUCCESS, msg=res) | 172 | self._task_(func.__name__, client, taskid, code=TaskStatus.SUCCESS, msg=res) |
| 171 | 173 | ||
| @@ -187,6 +189,7 @@ class Monitor(callback.CallBack): | @@ -187,6 +189,7 @@ class Monitor(callback.CallBack): | ||
| 187 | else: | 189 | else: |
| 188 | try: | 190 | try: |
| 189 | client = self._get_member(target) | 191 | client = self._get_member(target) |
| 192 | + assert hasattr(client, 'extend'), '帐号未登录' | ||
| 190 | if hasattr(client.extend, type_): | 193 | if hasattr(client.extend, type_): |
| 191 | func = getattr(client.extend, type_) | 194 | func = getattr(client.extend, type_) |
| 192 | else: | 195 | else: |
| @@ -195,4 +198,4 @@ class Monitor(callback.CallBack): | @@ -195,4 +198,4 @@ class Monitor(callback.CallBack): | ||
| 195 | kwargs = parameter.join(func, payload) | 198 | kwargs = parameter.join(func, payload) |
| 196 | self.executor.submit(self.thread, client, taskid, kwargs) | 199 | self.executor.submit(self.thread, client, taskid, kwargs) |
| 197 | except BaseException as err: | 200 | except BaseException as err: |
| 198 | - self._socket.send({'error': repr(err)}) | 201 | + self._task_(type_, Munch(email=target), taskid, code=TaskStatus.EXCEPTION, msg={'error': repr(err)}) |
| @@ -46,13 +46,29 @@ class WorkPlace(): | @@ -46,13 +46,29 @@ class WorkPlace(): | ||
| 46 | return data | 46 | return data |
| 47 | 47 | ||
| 48 | @classmethod | 48 | @classmethod |
| 49 | - def from_dict(cls,data:dict): | 49 | + def from_dict(cls, data: dict): |
| 50 | self = cls() | 50 | self = cls() |
| 51 | - for k,v in data.items(): | ||
| 52 | - if hasattr(self,k): | ||
| 53 | - setattr(self,k,v) | ||
| 54 | - return self | 51 | + for k, v in data.items(): |
| 52 | + if hasattr(self, k): | ||
| 53 | + setattr(self, k, v) | ||
| 54 | + | ||
| 55 | + start_time = [] | ||
| 56 | + end_time = [] | ||
| 57 | + for x in ['year', 'month', 'day']: | ||
| 58 | + if data.get(f'date_start[{x}]'): | ||
| 59 | + start_time.append(int(data.get(f'date_start[{x}]'))) | ||
| 60 | + | ||
| 61 | + if data.get(f'date_end[{x}]'): | ||
| 62 | + end_time.append(int(data.get(f'date_end[{x}]'))) | ||
| 63 | + if start_time: | ||
| 64 | + self.start_time = datetime.date(*start_time) | ||
| 65 | + | ||
| 66 | + if end_time: | ||
| 67 | + self.end_time = datetime.date(*end_time) | ||
| 68 | + else: | ||
| 69 | + self.current = True | ||
| 55 | 70 | ||
| 71 | + return self | ||
| 56 | 72 | ||
| 57 | 73 | ||
| 58 | @attrs(cmp=False) | 74 | @attrs(cmp=False) |
| @@ -312,19 +312,29 @@ class FacebookClient(Client): | @@ -312,19 +312,29 @@ class FacebookClient(Client): | ||
| 312 | return {"success": True} | 312 | return {"success": True} |
| 313 | return res | 313 | return res |
| 314 | 314 | ||
| 315 | - def addWorkPlace(self, workplace: WorkPlace): | 315 | + def addWorkPlace(self, workplace: WorkPlace, value='EVERYONE'): |
| 316 | '''添加工作经历''' | 316 | '''添加工作经历''' |
| 317 | + value = PostParam.__dict__.get(value).value | ||
| 317 | data = { | 318 | data = { |
| 318 | # 'hub_id': '142351455848493', | 319 | # 'hub_id': '142351455848493', |
| 319 | 'type': '2002', | 320 | 'type': '2002', |
| 320 | 'ref': 'about_tab', | 321 | 'ref': 'about_tab', |
| 321 | 'action_type': 'add', # add | edit | 322 | 'action_type': 'add', # add | edit |
| 322 | 'experience_id': '0', | 323 | 'experience_id': '0', |
| 323 | - 'privacy[741155019280009]': PostParam.EVERYONE.value | 324 | + 'privacy[741155019280009]': value |
| 324 | } | 325 | } |
| 325 | data.update(workplace.to_dict()) | 326 | data.update(workplace.to_dict()) |
| 326 | res = self._post('/profile/edit/work/save/', data) | 327 | res = self._post('/profile/edit/work/save/', data) |
| 327 | - return res | 328 | + try: |
| 329 | + return { | ||
| 330 | + 'success': True, | ||
| 331 | + 'setting': res['jsmods']['require'][1][3][0]['props'] | ||
| 332 | + } | ||
| 333 | + except: | ||
| 334 | + return { | ||
| 335 | + 'success': False, | ||
| 336 | + 'error': res['jsmods']['require'] | ||
| 337 | + } | ||
| 328 | 338 | ||
| 329 | def addCollege(self, college: College): | 339 | def addCollege(self, college: College): |
| 330 | '''添加教育记录''' | 340 | '''添加教育记录''' |
-
请 注册 或 登录 后发表评论