79 lines
2.7 KiB
Python
79 lines
2.7 KiB
Python
import effect.effectinstagram
|
|
import effect.effecterror
|
|
import effect.effectkakaostory
|
|
from base.baseclasses import printl
|
|
import sys
|
|
import base.baseclasses
|
|
|
|
browser_opt = ('chrome', "ie", "opera", "firefox")
|
|
platform_opt = ('instagram', 'kakaostory', 'navercafe', "facebook")
|
|
|
|
|
|
def get_browser_info(platform_, file_name="browser.txt"):
|
|
if sys.platform == 'win32':
|
|
options = {'default': 'ie'}
|
|
else:
|
|
options = {'default': 'firefox'}
|
|
try:
|
|
with open(file_name, 'r') as f:
|
|
for line in f:
|
|
if line.startswith("#"):
|
|
continue
|
|
elif len(line.strip()) < 1:
|
|
continue
|
|
else:
|
|
platform, browser = line.split("=")
|
|
platform = platform.strip()
|
|
browser = browser.strip()
|
|
if (platform not in options.keys() and platform not in platform_opt) or browser not in browser_opt:
|
|
pass
|
|
else:
|
|
options[platform] = browser
|
|
finally:
|
|
return options.get(platform_, options['default'])
|
|
|
|
|
|
def get_effect_process(platform_, event_num, url):
|
|
if platform_ == 'instagram':
|
|
return effect.effectinstagram.EffectInsta(int(event_num), int(event_num), url)
|
|
|
|
else:
|
|
browser_info = get_browser_info(platform_)
|
|
browser = base.baseclasses.Browser()
|
|
driver = browser.get_new_driver(browser_info)
|
|
if platform_ == 'kakaostory':
|
|
return effect.effectkakaostory.EffectKakaostory(int(event_num), int(event_num), url, driver)
|
|
else:
|
|
return None
|
|
|
|
if __name__ == '__main__':
|
|
"""
|
|
sys.argv[0] effectprocess.py
|
|
sys.argv[1] instagram, kakaostory, facebook
|
|
sys.argv[2] event_num
|
|
sys.argv[3] url
|
|
"""
|
|
|
|
if len(sys.argv) != 4:
|
|
printl("x!@#!@#!@#e010!@#check argument")
|
|
exit(1)
|
|
|
|
try:
|
|
effect_process = get_effect_process(sys.argv[1], sys.argv[2], sys.argv[3])
|
|
effect_process.start()
|
|
except effect.effecterror.EffectException as e:
|
|
printl("x!@#" + str(sys.argv[2]) + "!@#" + str(sys.argv[3]) + "!@#" + str(e))
|
|
if sys.argv[1] != 'instagram':
|
|
effect_process.driver.close()
|
|
exit(1)
|
|
except Exception as e:
|
|
printl("x!@#" + str(sys.argv[2]) + "!@#" + str(sys.argv[3]) + "!@#" + 'e012' + str(e))
|
|
if sys.argv[1] != 'instagram':
|
|
effect_process.driver.close()
|
|
exit(1)
|
|
|
|
printl("o!@#" + str(sys.argv[2]) + "!@#" + str(sys.argv[3]))
|
|
if sys.argv[1] != 'instagram':
|
|
effect_process.driver.close()
|
|
exit(0)
|