|
@@ -63,43 +63,54 @@ def carry_plan(user_id, ad_plan_list, log_ad, db, cookie_canuse):
|
|
|
|
|
|
|
|
|
cookie_acion(db, log_ad, cookie_canuse, user_id)
|
|
|
-
|
|
|
- for _ in ad_plan_list:
|
|
|
- service_name = _['service_name']
|
|
|
- wechat_name = _['wechat_name']
|
|
|
-
|
|
|
- log_ad.select_ad_master(service_name, wechat_name)
|
|
|
- create_ad_layout = CreateAd(login_ad=log_ad, service_name=service_name, wechat_name=wechat_name)
|
|
|
- create_ad_layout.check_sucess_ready()
|
|
|
-
|
|
|
- layout_name = _['idea']['jump_type_page_type']['layout_name'].replace(' ', '')[:29]
|
|
|
- if create_ad_layout.check_sucess(layout_name=layout_name):
|
|
|
- res = {'sucess': True, 'result_info': '已经创建过对应落地页'}
|
|
|
- sql_tools.action_record(res, sql_session, layout_create_action, user_id, layout_name, action_record_table,
|
|
|
+ try:
|
|
|
+ for _ in ad_plan_list:
|
|
|
+ service_name = _['service_name']
|
|
|
+ wechat_name = _['wechat_name']
|
|
|
+
|
|
|
+ log_ad.select_ad_master(service_name, wechat_name)
|
|
|
+ create_ad_layout = CreateAd(login_ad=log_ad, service_name=service_name, wechat_name=wechat_name)
|
|
|
+ create_ad_layout.check_sucess_ready()
|
|
|
+
|
|
|
+ layout_name = _['idea']['jump_type_page_type']['layout_name'].replace(' ', '')[:29]
|
|
|
+ if create_ad_layout.check_sucess(layout_name=layout_name):
|
|
|
+ res = {'sucess': True, 'result_info': '已经创建过对应落地页'}
|
|
|
+ sql_tools.action_record(res, sql_session, layout_create_action, user_id, layout_name,
|
|
|
+ action_record_table,
|
|
|
+ service_name, wechat_name)
|
|
|
+
|
|
|
+ else:
|
|
|
+
|
|
|
+ create_ad_layout.get_into_create_page()
|
|
|
+ layout_typesetting_dict = sql_tools.get_layout_typesetting(sql_session, user_id,
|
|
|
+ typesetting_name=layout_name)
|
|
|
+ layout_typesetting_dict = json.loads(layout_typesetting_dict)
|
|
|
+ res = create_ad_layout.create_layout(layout_typesetting_dict)
|
|
|
+ sql_tools.action_record(res, sql_session, layout_create_action, user_id, layout_name,
|
|
|
+ action_record_table,
|
|
|
+ service_name, wechat_name)
|
|
|
+ log_ad.refresh_driver()
|
|
|
+
|
|
|
+
|
|
|
+ log_ad.select_ad_master(service_name, wechat_name)
|
|
|
+ plan_name = _['title'].replace(' ', '')[:29]
|
|
|
+
|
|
|
+
|
|
|
+ create_ad_plan = CreateAdPlan(login_ad=log_ad, task=_)
|
|
|
+ res = create_ad_plan.run()
|
|
|
+
|
|
|
+ sql_tools.action_record(res, sql_session, ad_plan_create_action, user_id, plan_name, action_record_table,
|
|
|
service_name, wechat_name)
|
|
|
-
|
|
|
- else:
|
|
|
-
|
|
|
- create_ad_layout.get_into_create_page()
|
|
|
- layout_typesetting_dict = sql_tools.get_layout_typesetting(sql_session, user_id,
|
|
|
- typesetting_name=layout_name)
|
|
|
- layout_typesetting_dict = json.loads(layout_typesetting_dict)
|
|
|
- res = create_ad_layout.create_layout(layout_typesetting_dict)
|
|
|
- sql_tools.action_record(res, sql_session, layout_create_action, user_id, layout_name, action_record_table,
|
|
|
- service_name, wechat_name)
|
|
|
- log_ad.refresh_driver()
|
|
|
-
|
|
|
-
|
|
|
- log_ad.select_ad_master(service_name, wechat_name)
|
|
|
- plan_name = _['title'].replace(' ', '')[:29]
|
|
|
-
|
|
|
-
|
|
|
- create_ad_plan = CreateAdPlan(login_ad=log_ad, task=_)
|
|
|
- res = create_ad_plan.run()
|
|
|
-
|
|
|
- sql_tools.action_record(res, sql_session, ad_plan_create_action, user_id, plan_name, action_record_table,
|
|
|
- service_name, wechat_name)
|
|
|
-
|
|
|
+ log_ad.refresh_driver()
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ finally:
|
|
|
+ try:
|
|
|
+ print('任务结束')
|
|
|
+ log_ad.driver.quit()
|
|
|
+ except:
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
|