コード例 #1
0
def search_jobs(keywords, page=1, data_collection=[]):
    search_template = "curl 'https://chalice-search-api.cloud.seek.com.au/search?siteKey=AU-Main&sourcesystem=houston&userqueryid=97ec6621797cfebd8a0f96a5bc59d139-1449239&userid=2734ad6f-4c64-49e0-aff0-6f615ec2cb82&usersessionid=2734ad6f-4c64-49e0-aff0-6f615ec2cb82&eventCaptureSessionId=bdbc2f3d-c84b-40c1-bf60-bad7564b3380&where=All+Australia&page=<PAGE>&seekSelectAllPages=true&keywords=<KEYWORDS>&include=seodata&isDesktop=true' -H 'Origin: https://www.seek.com.au' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'Referer: https://www.seek.com.au/java-java-jobs' -H 'Connection: keep-alive' -H 'X-Seek-Site: Chalice' --compressed"
    search_replace_dict = {
        "<KEYWORDS>": [urllib.parse.quote_plus(keywords)],
        "<PAGE>": [str(page)],
    }
    if not do_query_listings:
        print(">> Loading queries from listings.json")
        with open(os.path.join(Config.data_path, "listings.json"),
                  'r') as infile:
            return json.load(infile)
    if Config.auto_y or input("Run search jobs (y)? ") == 'y':
        executor = CommandExecutor()
        raw_executor_results = executor.run_commands_on_workers(
            commands=CommandGenerator.generate_commands(
                search_template, search_replace_dict),
            workers=1)
        json_response = json.loads(
            raw_executor_results[0]['stdout'].decode('utf-8'))
        data_collection += json_response['data']
        print("Current data_collection size: ", len(data_collection))
        if len(data_collection) < json_response['totalCount']:
            return search_jobs(keywords, page + 1, data_collection)
        print(">> Saving to listings.json")
        with open(os.path.join(Config.data_path, "listings.json"),
                  'w') as outfile:
            json.dump(data_collection, outfile, indent=4)
        return data_collection
コード例 #2
0
def view_applications(ids):
    view_template = 'curl "https://ca-jobapply-ex-api.cloud.seek.com.au/jobs/<ID>/" -H "Origin: https://www.seek.com.au" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en-US,en;q=0.9" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" -H "Accept: application/json, text/plain, */*" -H "Referer: https://www.seek.com.au/job-apply/<ID>" -H "Connection: keep-alive" -H "X-Seek-Site: SEEK JobApply" --compressed'
    view_replace_dict = {
        "<ID>": ids,
    }
    if not do_query_applications:
        print(">> Loading queries from applications.json")
        with open(os.path.join(Config.data_path, "applications.json"),
                  'r') as infile:
            return json.load(infile)
    if Config.auto_y or input("Run view applications (y)? ") == 'y':
        executor = CommandExecutor()
        raw_executor_results = executor.run_commands_on_workers(
            commands=CommandGenerator.generate_commands(
                view_template, view_replace_dict),
            workers=20)
        raw_results = [raw_result for raw_result in raw_executor_results]
        results = [
            json.loads(raw_result['stdout'].decode('utf-8'))
            for raw_result in raw_results
        ]
        print(">> Saving to applications.json")
        with open(os.path.join(Config.data_path, "applications.json"),
                  'w') as outfile:
            json.dump(results, outfile, indent=4)
        return results
コード例 #3
0
def view_post(ids):
    view_template = 'curl "https://chalice-experience.cloud.seek.com.au/job/<ID>?isDesktop=true^&locale=AU" -H "Origin: https://www.seek.com.au" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en-US,en;q=0.9" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" -H "Accept: application/json, text/plain, */*" -H "Referer: https://www.seek.com.au/job/<ID>?type=standout" -H "If-None-Match: W/^\^"e86-I553tIAg7654QmbWH+FrADxPO7I^\^"" -H "Connection: keep-alive" -H "X-Seek-Site: Chalice" --compressed'
    view_replace_dict = {
        "<ID>": ids,
    }
    if not do_query_posts:
        print(">> Loading queries from posts.json")
        with open(os.path.join(Config.data_path, "posts.json"), 'r') as infile:
            return json.load(infile)
    if Config.auto_y or input("Run view posts (y)? ") == 'y':
        executor = CommandExecutor()
        raw_executor_results = executor.run_commands_on_workers(
            commands=CommandGenerator.generate_commands(
                view_template, view_replace_dict),
            workers=20)
        raw_results = [raw_result for raw_result in raw_executor_results]
        results = [
            json.loads(raw_result['stdout'].decode('utf-8'))
            for raw_result in raw_results
        ]
        print(">> Saving to posts.json")
        with open(os.path.join(Config.data_path, "posts.json"),
                  'w') as outfile:
            json.dump(results, outfile, indent=4)
        return results
コード例 #4
0
 def __init__(self, logger, disk_util, passphrase_filename, public_settings, distro_info):
     self.logger = logger
     self.executor = CommandExecutor(self.logger)
     self.disk_util = disk_util
     self.passphrase_filename = passphrase_filename  # WARNING: This may be null, in which case we mount the resource disk if its unencrypted and do nothing if it is.
     self.public_settings = public_settings
     self.distro_info = distro_info
コード例 #5
0
 def validate_vfat(self):
     """ Check for vfat module using modprobe and raise exception if not found """
     try:
         executor = CommandExecutor(self.logger)
         executor.Execute("modprobe vfat", True)
     except:
         raise RuntimeError(
             'Incompatible system, prerequisite vfat module was not found.')
コード例 #6
0
    def __init__(self, hutil, patching, logger, encryption_environment):
        self.encryption_environment = encryption_environment
        self.hutil = hutil
        self.distro_patcher = patching
        self.logger = logger
        self.ide_class_id = "{32412632-86cb-44a2-9b5c-50d1417354f5}"
        self.vmbus_sys_path = '/sys/bus/vmbus/devices'

        self.command_executor = CommandExecutor(self.logger)
コード例 #7
0
    def __init__(self, install_lib):
        self.__logger = ClientLogger.setup(phase='install')
        self.__command_executor = CommandExecutor(phase='install')

        self.__install_lib = install_lib
        self.__service_link = "/etc/init.d/{0}".format(
            PackageInfo.pip_package_name)
        self.__service_script = '{0}{1}/Service.py'.format(
            install_lib, PackageInfo.python_package_name)
コード例 #8
0
 def __init__(self, hutil, logger, distro_patcher):
     self.hutil = hutil
     self.logger = logger
     self.executor = CommandExecutor(self.logger)
     self.disk_util = DiskUtil(hutil=self.hutil,
                               patching=distro_patcher,
                               logger=self.logger,
                               encryption_environment=None)
     self.mapper_name = str(uuid.uuid4())
     self.mapper_path = self.DM_PREFIX + self.mapper_name
コード例 #9
0
    def __auto_update_timer_tick(self):
        if not self.__client.is_in_use():
            try:
                CommandExecutor().execute_commands([
                    '{0} update'.format(PackageInfo.pip_package_name)
                ])
            except Exception:
                pass

        self.__start_auto_update_timer()
コード例 #10
0
ファイル: ClientDaemon.py プロジェクト: lucosmic/tinkerAccess
    def update(opts, args):
        if not ClientDaemon.__is_in_use(opts, args):
            logger = ClientLogger.setup(opts)
            requested_version = args[1] if len(args) >= 2 else None
            if ClientDaemon.__should_update(opts, requested_version):
                try:
                    requested_package = PackageInfo.pip_package_name

                    # BUG: There is a big fat bug with pip that is causing it to redirect to
                    # install the latest version, even when a specific version is installed.
                    # I'll look into this when I get time.

                    if requested_version:
                        requested_package = '{0}=={1}'.format(requested_package, requested_version)

                    ClientDaemon.stop(opts, args)
                    CommandExecutor().execute_commands([
                        'pip install --upgrade --force-reinstall --ignore-installed --no-cache-dir {0}'
                        .format(requested_package)
                    ])
                except Exception as e:
                    msg = '{0} update failed, remediation maybe required!'.format(PackageInfo.pip_package_name)
                    logger.error(msg)
                    logger.exception(e)
                    raise e
                finally:
                    if not ClientDaemon.status(opts, args):
                        ClientDaemon.restart(opts, args)
            else:

                force_update_hint = 'Use the --force-update option to bypass ' \
                                    'the version check and re-install from PyPi.\n'\
                                    .format(
                                        PackageInfo.pip_package_name,
                                        PackageInfo.version
                                    )

                if not PackageInfo.version:
                    return [
                        'You are currently using a non-versioned build...\n',
                        force_update_hint
                    ], 1

                version = 'latest' if not requested_version else 'requested'
                return [
                    '{0} v{1} already matches the {2} version. \n'
                    'Use the --force-update option to bypass the version check and re-install.\n'.format(
                        PackageInfo.pip_package_name,
                        PackageInfo.version,
                        version
                    )], 1
        else:
            return ['{0} is currently in use, try again later...\n'.format(PackageInfo.pip_package_name)], 1
コード例 #11
0
    def run(opts, args):
        logger = ClientLogger.setup(opts)
        reboot_delay = opts.get(ClientOption.REBOOT_DELAY) * 60
        reboot_on_error = opts.get(ClientOption.REBOOT_ON_ERROR)

        try:
            with DeviceApi(opts) as device, \
                    Client(device, opts) as client, \
                    AutoUpdateTimer(client, opts) as auto_update_timer:

                device.on(
                    Channel.SERIAL,
                    direction=device.GPIO.IN,
                    call_back=client.handle_badge_code
                )

                device.on(
                    Channel.PIN,
                    pin=opts.get(ClientOption.PIN_LOGOUT),
                    direction=device.GPIO.RISING,
                    call_back=client.logout
                )

                client.idle()
                auto_update_timer.start()
                while not client.is_terminated():
                    logger.debug('%s is waiting...', PackageInfo.pip_package_name)
                    client.wait()

        except (KeyboardInterrupt, SystemExit) as e:
            pass

        except Exception as e:
            logger.exception(e)

            if reboot_on_error:

                # reboot is only supported on Raspberry PI devices
                # noinspection PyBroadException
                try:
                    # noinspection PyUnresolvedReferences
                    import RPi.GPIO
                    logger.error('Rebooting in %s minutes...', reboot_delay / 60)
                    CommandExecutor().execute_commands([
                        'sleep {0}s'.format(reboot_delay),
                        'reboot now'
                    ])
                except Exception:
                    pass
コード例 #12
0
ファイル: ClientDaemon.py プロジェクト: lucosmic/tinkerAccess
 def remove(opts, args):
     try:
         CommandExecutor().execute_commands([
             '{'
             '\tset +e',
             '\tservice tinker-access-client stop',
             '\tupdate-rc.d -f tinker-access-client remove',
             '\trm -rf /etc/init.d/tinker-access-client',
             '\twhile [[ $(pip uninstall tinker-access-client -y) == 0 ]]; do :; done',
             '\tfind /usr/local/lib/python2.7/dist-packages/ -name \'tinker[_-]access[_-]client*\' -type d -exec sudo rm -r "{}" \;',
             '\tsed -i.bak \'/^\/.*\/tinker_access_client$/s///g\' /usr/local/lib/python2.7/dist-packages/easy-install.pth',
             '} &> /dev/null'
         ])
     except Exception:
         pass
コード例 #13
0
def run(vk=vk_init()):
    parser = argparse.ArgumentParser()
    parser.add_argument("-start_time", type=int)
    args = parser.parse_args()

    command_executor = CommandExecutor(args.start_time, VERSION, storage)

    print("STARTED")
    send = vk.rest.post(
        "messages.send",
        peer_id=vk.user_id,
        message=f"<Started {VERSION}. {time.strftime('%H:%M:%S')}>",
        random_id=random.randint(-2147483648, 2147483647))
    while True:
        parse_messages(vk, command_executor)
コード例 #14
0
def search_seek(keywords,
                start=0,
                data_collection=[]
                ):  # https://au.indeed.com/viewjob?jk=23b529ed5c26e9af
    page_entries = 50
    search_template = "curl 'https://au.indeed.com/jobs?as_and=<KEYWORDS>&as_phr=&as_any=&as_not=&as_ttl=&as_cmp=&jt=all&st=&as_src=&salary=&radius=100&l=Melbourne+City+Centre+VIC&fromage=any&limit=50&start=<START>&sort=&psf=advsrch' -H 'authority: au.indeed.com' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' --compressed"
    search_replace_dict = {
        "<KEYWORDS>": [urllib.parse.quote_plus(keywords)],
        "<PAGE>": [str(start)],
    }
    if not do_seek_search: pass
    #print(">> Loading queries from listings.json")
    #with open(os.path.join(Config.data_path, "listings.json"), 'r') as infile:
    #    return json.load(infile)
    if Config.auto_y or input("Run seek jobs (y)? ") == 'y':
        executor = CommandExecutor()
        raw_executor_results = executor.run_commands_on_workers(
            commands=CommandGenerator.generate_commands(
                search_template, search_replace_dict),
            workers=1)
コード例 #15
0
    def __init__(self,
                 logger,
                 hutil,
                 disk_util,
                 ongoing_item_config,
                 patching,
                 encryption_environment,
                 status_prefix=''):
        """
        copy_total_size is in bytes.
        """
        self.command_executer = CommandExecutor(logger)
        self.ongoing_item_config = ongoing_item_config
        self.total_size = self.ongoing_item_config.get_current_total_copy_size(
        )
        self.block_size = self.ongoing_item_config.get_current_block_size()
        self.source_dev_full_path = self.ongoing_item_config.get_current_source_path(
        )
        self.destination = self.ongoing_item_config.get_current_destination()
        self.current_slice_index = self.ongoing_item_config.get_current_slice_index(
        )
        self.from_end = self.ongoing_item_config.get_from_end()

        self.last_slice_size = self.total_size % self.block_size
        # we add 1 even the last_slice_size is zero.
        self.total_slice_size = (
            (self.total_size - self.last_slice_size) / self.block_size) + 1

        self.status_prefix = status_prefix
        self.encryption_environment = encryption_environment
        self.logger = logger
        self.patching = patching
        self.disk_util = disk_util
        self.hutil = hutil
        self.tmpfs_mount_point = "/mnt/azure_encrypt_tmpfs"
        self.slice_file_path = self.tmpfs_mount_point + "/slice_file"
        self.copy_command = self.patching.dd_path
コード例 #16
0
 def setUp(self):
     self.executor = CommandExecutor().set_logger(Logger().set_none())
     self.executor.perform_console_reset = False
     self.execs = []
コード例 #17
0
ファイル: Driver.py プロジェクト: arpitrathi/parking_lot
 def __init__(self):
     self.commandExecutor = CommandExecutor()
コード例 #18
0
ファイル: jmake.py プロジェクト: linuxscn/mysource
#!/usr/bin/env python3
import sys
from CommandDispatcher import CommandDispatcher
from CommandExecutor import CommandExecutor
from Logger import LOG


dispatcher = CommandDispatcher(CommandExecutor().set_logger(LOG.set_debug()))
sys.exit(dispatcher.dispatch_from_params(sys.argv))