Exemplo n.º 1
0
    SUPPORTED_SUMMARIZERS,
    DEFAULT_TOKENIZER,
    DEFAULT_TEXT_SEPERATOR,
    DEFAULT_SENTENCE_SEPERATOR,
    DEFAULT_SENTENCE_COUNT
)

from tools.logger import Logger
from tools.tokenizer import Tokenizer

dirname, filename = os.path.split(os.path.abspath(__file__))
os.chdir(dirname)  # Change the current working directory
# to the directory of the script. All file loads are relative
# to the script directory.

LOGGER = Logger.getInstance()

try:  # Used for Python 2 compatibility
    import sys
    reload(sys)
    sys.setdefaultencoding('utf-8')
except NameError:
    pass


class benchmark:
    def __init__(self):
        # Generate Benchmark Tool Folders
        createFolderIfNotExists(
            os.path.join('..', 'data', 'generated_summaries'))
Exemplo n.º 2
0
def start(args):
    if not Path(args.dirpath).exists():
        print("[ERROR] Specified dirpath does not exist!")
        exit()

    config.check_json_config()

    if config.data.web_browser_driver == "":
        print(
            "[ERROR]: web_browser_driver parameter wasn't specified in neither config file nor command line arguments."
        )
        exit()

    Logger.getInstance()

    while True:
        config.check_json_config()

        if not (datetime.datetime.now().hour > config.data.start_hour
                and datetime.datetime.now().hour < config.data.end_hour):
            actions.sleep()
            continue

        instagram.actions.driver_init()

        # Log In
        instagram.actions.log_in()
        instagram.actions.get_following_count()
        instagram.actions.get_followers_count()

        ActionBlock = False

        def run():
            nonlocal ActionBlock

            try:
                instagram.actions.like_likelist(3)
            except instagram.exceptions.LimitReached:
                return
            except instagram.exceptions.ActionBlock:
                actions.change_site_main()
                ActionBlock = True
                return

            SITES = []
            with open(Path(config.data.sites_file), encoding="UTF-8") as f:
                SITES = [line.strip() for line in f.readlines()]

            while len(SITES) > 0:
                site = SITES.pop(random.randint(0, len(SITES) - 1))
                instagram.actions.change_site(site)

                try:
                    instagram.actions.work_on_site()
                except instagram.exceptions.LimitReached:
                    return
                except instagram.exceptions.ActionBlock:
                    actions.change_site_main()
                    ActionBlock = True
                    return

        run()

        if not ActionBlock:
            try:
                instagram.actions.unfollow_in_profile()
            except instagram.exceptions.ActionBlock:
                instagram.actions.change_site_profile()
                ActionBlock = True

        instagram.actions.change_site_profile()
        instagram.actions.log_out()
        instagram.actions.driver_close()

        if ActionBlock:
            config.delete_cookies()

        instagram.actions.sleep()