text
stringlengths
81
112k
持久化会话信息 def persist(self): """ 持久化会话信息 """ with open(self.persist_file, 'w+') as f: json.dump({ 'cookies': self.cookies, 'user_alias': self.user_alias, }, f, indent=2) self.logger.debug('persist session to <%s>' % self....
加载会话信息 def load(self): """ 加载会话信息 """ if not os.path.isfile(self.persist_file): return with open(self.persist_file, 'r') as f: cfg = json.load(f) or {} self.cookies = cfg.get('cookies', {}) self.user_alias = cfg.get('user_alias') o...
更新会话信息,主要是ck, user_alias def flush(self): """ 更新会话信息,主要是ck, user_alias """ if 'dbcl2' not in self.cookies: return r = self.req(API_ACCOUNT_HOME) if RE_SESSION_EXPIRE.search(r.url): return self.expire() self.cookies.update(dict(r.cookies)) ...
登录 :type username: str :param username: 用户名(手机号或者邮箱) :type password: str :param password: 密码 def login(self, username, password): """ 登录 :type username: str :param username: 用户名(手机号或者邮箱) :type password: str ...
如果遭遇验证码,用这个接口 :type cookies: str|dict :param cookies: cookie字符串或者字典 :return: self def use(self, cookies): """ 如果遭遇验证码,用这个接口 :type cookies: str|dict :param cookies: cookie字符串或者字典 :return: self """ self.cookies = dict([item...
登出会话 :return: self def logout(self): """ 登出会话 :return: self """ self.req(API_ACCOUNT_LOGOUT % self.ck()) self.cookies = {} self.user_alias = None self.persist()
Upload bundle and deploy to deployment group. This includes the bundle-action. :param applicationName: :param deploymentGroupName: :param deploymentConfigName: :param bucket: :param bundlefile: :return: deploymentId from create_deployment def deploy(awsclient, applicationName, deploymentGr...
Wait until an deployment is in an steady state and output information. :param deployment_id: :param iterations: :return: exit_code def output_deployment_status(awsclient, deployment_id, iterations=100): """Wait until an deployment is in an steady state and output information. :param deployment_id...
stop tenkai deployment. :param awsclient: :param deployment_id: def stop_deployment(awsclient, deployment_id): """stop tenkai deployment. :param awsclient: :param deployment_id: """ log.info('Deployment: %s - stopping active deployment.', deployment_id) client_codedeploy = awsclient.g...
list deployment instances. :param awsclient: :param deployment_id: def _list_deployment_instances(awsclient, deployment_id): """list deployment instances. :param awsclient: :param deployment_id: """ client_codedeploy = awsclient.get_client('codedeploy') instances = [] next_token ...
instance summary. :param awsclient: :param deployment_id: :param instance_id: return: status, last_event def _get_deployment_instance_summary(awsclient, deployment_id, instance_id): """instance summary. :param awsclient: :param deployment_id: :param instance_id: return: status, la...
Gets you the diagnostics details for the first 'Failed' event. :param awsclient: :param deployment_id: :param instance_id: return: None or (error_code, script_name, message, log_tail) def _get_deployment_instance_diagnostics(awsclient, deployment_id, instance_id): """Gets you the diagnostics detai...
summary :param awsclient: :param deployment_id: def output_deployment_summary(awsclient, deployment_id): """summary :param awsclient: :param deployment_id: """ log.info('\ndeployment summary:') log.info('%-22s %-12s %s', 'Instance ID', 'Status', 'Most recent event') for instance_i...
diagnostics :param awsclient: :param deployment_id: def output_deployment_diagnostics(awsclient, deployment_id, log_group, start_time=None): """diagnostics :param awsclient: :param deployment_id: """ headline = False for instance_id in _list_deployment_instances(awsclient, deployment_...
:return: :rtype: bool def is_type(self): """ :return: :rtype: bool """ if self.__is_type_result is not None: return self.__is_type_result self.__is_type_result = self.__is_type() return self.__is_type_result
:raises TypeError: If the value is not matched the type that the class represented. def validate(self, error_message=None): """ :raises TypeError: If the value is not matched the type that the class represented. """ if self.is_type(): return ...
:return: Converted value. :raises typepy.TypeConversionError: If the value cannot convert. def convert(self): """ :return: Converted value. :raises typepy.TypeConversionError: If the value cannot convert. """ if self.is_type(): return...
always_fails :param work_dict: dictionary for key/values def always_fails( self, work_dict): """always_fails :param work_dict: dictionary for key/values """ label = "always_fails" log.info(("task - {} - start " "work_dict={}") .format(label, ...
Build name from prefix and name + type :param name: Name of the role/policy :param is_policy: True if policy should be added as suffix :param prefix: True if prefix should be added :return: Joined name def name_build(self, name, is_policy=False, prefix=True): """ Build n...
Transforms name to AWS valid characters and adds prefix and type :param name: Name of the role/policy :param is_policy: True if policy should be added as suffix :param prefix: True if prefix should be added :return: Transformed and joined name def name_strip(self, name, is_policy=False,...
Generate policy for IAM cloudformation template :param name: Name of the policy :param statements: The "rules" the policy should have :param roles: The roles associated with this policy :param is_managed_policy: True if managed policy :return: Ref to new policy def build_policy(...
Generate bucket policy for S3 bucket :param bucket: The bucket to attach policy to :param name: The name of the bucket (to generate policy name from it) :param statements: The "rules" the policy should have :return: Ref to new policy def build_policy_bucket(self, bucket, name, statement...
Generate role for IAM cloudformation template :param name: Name of role :param policies: List of policies to attach to this role (False = none) :return: Ref to new role def build_role(self, name, policies=False): """ Generate role for IAM cloudformation template :param n...
Generate S3 bucket statement :param name: Name of the bucket :param lifecycle_configuration: Additional lifecycle configuration (default=False) :param use_plain_name: Just use the given name and do not add prefix :return: Ref to new bucket def build_bucket(self, name, lifecycle_configur...
label SPACE num Allocate space on the stack. `num` is the number of bytes to allocate def directive_SPACE(self, label, params): """ label SPACE num Allocate space on the stack. `num` is the number of bytes to allocate """ # TODO allow equations params = pa...
label DCD value[, value ...] Allocate a word space in read only memory for the value or list of values def directive_DCD(self, label, params): """ label DCD value[, value ...] Allocate a word space in read only memory for the value or list of values """ # TODO make...
label DCH value[, value ...] Allocate a half word space in read only memory for the value or list of values def directive_DCH(self, label, params): """ label DCH value[, value ...] Allocate a half word space in read only memory for the value or list of values """ #...
label DCB value[, value ...] Allocate a byte space in read only memory for the value or list of values def directive_DCB(self, label, params): """ label DCB value[, value ...] Allocate a byte space in read only memory for the value or list of values """ # TODO make...
get_celery_app :param name: name for this app :param auth_url: celery broker :param backend_url: celery backend :param include_tasks: list of modules containing tasks to add :param ssl_options: security options dictionary :param trasport_options: transport options dictionary :param path_to_...
Determine if the parameters meet the specifications kwargs contains lists grouped by their parameter rules are defined by methods starting with 'rule_' :param kwargs: :return: def check_arguments(self, **kwargs): """ Determine if the parameters meet the specifications ...
Make these two keys have the same value :param key1: :param key2: :return: def link(self, key1, key2): """ Make these two keys have the same value :param key1: :param key2: :return: """ # TODO make this have more than one key linked ...
A method decorator that filters out sign_original_specals coming from models that don't have fields that function as ImageFieldSourceGroup sources. def instance_ik_model_receiver(fn): """ A method decorator that filters out sign_original_specals coming from models that don't have fields that function a...
Relay source group signals to the appropriate spec strategy. def source_group_receiver(self, sender, source, signal, **kwargs): """ Relay source group signals to the appropriate spec strategy. """ from imagekit.cachefiles import ImageCacheFile source_group = sender ins...
Stores hashes of the source image files so that they can be compared later to see whether the source image has changed (and therefore whether the spec file needs to be regenerated). def update_source_hashes(self, instance): """ Stores hashes of the source image files so that they can be...
Returns a list of the source fields for the given instance. def get_source_fields(self, instance): """ Returns a list of the source fields for the given instance. """ return set(src.image_field for src in self._source_groups if isinstance(instance, ...
on_success http://docs.celeryproject.org/en/latest/reference/celery.app.task.html :param retval: return value :param task_id: celery task id :param args: arguments passed into task :param kwargs: keyword arguments passed into task def on_success(self, retval, task_id, args, kw...
on_failure http://docs.celeryproject.org/en/latest/userguide/tasks.html#task-inheritance :param exc: exception :param task_id: task id :param args: arguments passed into task :param kwargs: keyword arguments passed into task :param einfo: exception info def on_failure(...
Check if the hook configuration is absent or has both register AND deregister. :param module: :return: True if valid plugin / module. def check_hook_mechanism_is_intact(module): """Check if the hook configuration is absent or has both register AND deregister. :param module: :return: True if valid...
Render dot output for cloudformation.template in json format. def cfn_viz(template, parameters={}, outputs={}, out=sys.stdout): """Render dot output for cloudformation.template in json format. """ known_sg, open_sg = _analyze_sg(template['Resources']) (graph, edges) = _extract_graph(template.get('Descr...
Determine fillcolor for resources (public ones in this case) def _get_fillcolor(resource_type, properties, known_sg=[], open_sg=[]): """Determine fillcolor for resources (public ones in this case) """ fillcolor = None # check security groups if 'SecurityGroups' in properties: # check for ex...
Render template into svg file using the dot command (must be installed). :param dotfile: path to the dotfile :param outfile: filename for the output file :return: def svg_output(dotfile, outfile='cloudformation.svg'): """Render template into svg file using the dot command (must be installed). :pa...
Start the Helper controller either in the foreground or as a daemon process. :param controller_class: The controller class handle to create and run :type controller_class: callable def start(controller_class): """Start the Helper controller either in the foreground or as a daemon process. :pa...
Run to the current end of the program or a number of steps :return: def run(self, steps=float('inf')): """ Run to the current end of the program or a number of steps :return: """ while len(self.program) > (self.register['PC'] - 1): steps -= 1 if s...
Helper function that checks the input object type against each in a list of classes. This function also allows the input value to be equal to None. :param name: Name of the object. :param obj: Object to check the type of. :param args: List of classes. :raises TypeError: if the i...
Helper function that checks the input object type against each in a list of classes, or if the input object is a list, each value that it contains against that list. :param name: Name of the object. :param obj: Object to check the type of. :param args: List of classes. :raises T...
Helper function that checks the input object as a list then recursively until nested_level is 1. :param name: Name of the object. :param obj: Object to check the type of. :param nested_level: Integer with the current nested level. :param args: List of classes. :raises TypeError:...
B label Unconditional branch to the address at label def B(self, params): """ B label Unconditional branch to the address at label """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exists=(label,)) # TODO check i...
BL label Branch to the label, storing the next instruction in the Link Register def BL(self, params): """ BL label Branch to the label, storing the next instruction in the Link Register """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_...
BLX Rj Branch to the address in Rj, storing the next instruction in the Link Register def BLX(self, params): """ BLX Rj Branch to the address in Rj, storing the next instruction in the Link Register """ Rj = self.get_one_parameter(self.ONE_PARAMETER, params) s...
BX Rj Jump to the address in the Link Register def BX(self, params): """ BX Rj Jump to the address in the Link Register """ Rj = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(LR_or_general_purpose_registers=(Rj,)) def BX_func...
Returns a PEP 440-compliant version number from VERSION. Created by modifying django.utils.version.get_version def get_version(version): """ Returns a PEP 440-compliant version number from VERSION. Created by modifying django.utils.version.get_version """ # Now build the two parts of the ver...
Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the development version numbers. def get_git_changeset(): "...
Load cloudformation template from path. :param path: Absolute or relative path of cloudformation template. Defaults to cwd. :return: module, success def load_cloudformation_template(path=None): """Load cloudformation template from path. :param path: Absolute or relative path of cloudformation templat...
get differences between local config and currently active config def get_parameter_diff(awsclient, config): """get differences between local config and currently active config """ client_cf = awsclient.get_client('cloudformation') try: stack_name = config['stack']['StackName'] if stack_...
Invoke the pre_hook BEFORE the config is read. :param awsclient: :param cloudformation: def call_pre_hook(awsclient, cloudformation): """Invoke the pre_hook BEFORE the config is read. :param awsclient: :param cloudformation: """ # TODO: this is deprecated!! move this to glomex_config_read...
Deploy the stack to AWS cloud. Does either create or update the stack. :param conf: :param override_stack_policy: :return: exit_code def deploy_stack(awsclient, context, conf, cloudformation, override_stack_policy=False): """Deploy the stack to AWS cloud. Does either create or update the stack. :...
Delete the stack from AWS cloud. :param awsclient: :param conf: :param feedback: print out stack events (defaults to True) def delete_stack(awsclient, conf, feedback=True): """Delete the stack from AWS cloud. :param awsclient: :param conf: :param feedback: print out stack events (defaults...
Print out the list of stacks deployed at AWS cloud. :param awsclient: :return: def list_stacks(awsclient): """Print out the list of stacks deployed at AWS cloud. :param awsclient: :return: """ client_cf = awsclient.get_client('cloudformation') response = client_cf.list_stacks( ...
Print out the change_set to console. This needs to run create_change_set first. :param awsclient: :param change_set_name: :param stack_name: def describe_change_set(awsclient, change_set_name, stack_name): """Print out the change_set to console. This needs to run create_change_set first. ...
Delete specified change set. Currently we only use this during automated regression testing. But we have plans so lets locate this functionality here :param awsclient: :param change_set_name: :param stack_name: def delete_change_set(awsclient, change_set_name, stack_name): """Delete specified ...
Writes the template to disk def write_template_to_file(conf, template_body): """Writes the template to disk """ template_file_name = _get_stack_name(conf) + '-generated-cf-template.json' with open(template_file_name, 'w') as opened_file: opened_file.write(template_body) print('wrote cf-temp...
call cloudformation to generate the template (json format). :param context: :param config: :param cloudformation: :return: def generate_template(context, config, cloudformation): """call cloudformation to generate the template (json format). :param context: :param config: :param cloud...
collect info and output to console :param awsclient: :param config: :param json: True / False to use json format as output :return: def info(awsclient, config, format=None): """ collect info and output to console :param awsclient: :param config: :param json: True / False to use js...
BCC label Branch to the instruction at label if the C flag is not set def BCC(self, params): """ BCC label Branch to the instruction at label if the C flag is not set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exi...
BCS label Branch to the instruction at label if the C flag is set def BCS(self, params): """ BCS label Branch to the instruction at label if the C flag is set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exists=(lab...
BEQ label Branch to the instruction at label if the Z flag is set def BEQ(self, params): """ BEQ label Branch to the instruction at label if the Z flag is set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exists=(lab...
BGE label Branch to the instruction at label if the N flag is the same as the V flag def BGE(self, params): """ BGE label Branch to the instruction at label if the N flag is the same as the V flag """ label = self.get_one_parameter(self.ONE_PARAMETER, params) ...
BGT label Branch to the instruction at label if the N flag is the same as the V flag and the Z flag is not set def BGT(self, params): """ BGT label Branch to the instruction at label if the N flag is the same as the V flag and the Z flag is not set """ label = self.get...
BHI label Branch to the instruction at label if the C flag is set and the Z flag is not set def BHI(self, params): """ BHI label Branch to the instruction at label if the C flag is set and the Z flag is not set """ label = self.get_one_parameter(self.ONE_PARAMETER, par...
BHS label Branch to the instruction at label if the C flag is set def BHS(self, params): """ BHS label Branch to the instruction at label if the C flag is set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exists=(lab...
BLE label Branch to the instruction at label if the Z flag is set or if the N flag is not the same as the V flag def BLE(self, params): """ BLE label Branch to the instruction at label if the Z flag is set or if the N flag is not the same as the V flag """ label = self...
BLO label Branch to the instruction at label if the C flag is not set def BLO(self, params): """ BLO label Branch to the instruction at label if the C flag is not set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exi...
BLS label Branch to the instruction at label if the C flag is not set or the Z flag is set def BLS(self, params): """ BLS label Branch to the instruction at label if the C flag is not set or the Z flag is set """ label = self.get_one_parameter(self.ONE_PARAMETER, param...
BLT label Branch to the instruction at label if the N flag is not the same as the V flag def BLT(self, params): """ BLT label Branch to the instruction at label if the N flag is not the same as the V flag """ label = self.get_one_parameter(self.ONE_PARAMETER, params) ...
BMI label Branch to the instruction at label if the N flag is set def BMI(self, params): """ BMI label Branch to the instruction at label if the N flag is set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exists=(lab...
BNE label Branch to the instruction at label if the Z flag is not set def BNE(self, params): """ BNE label Branch to the instruction at label if the Z flag is not set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exi...
BPL label Branch to the instruction at label if the N flag is set def BPL(self, params): """ BPL label Branch to the instruction at label if the N flag is set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exists=(lab...
BVC label Branch to the instruction at label if the V flag is not set def BVC(self, params): """ BVC label Branch to the instruction at label if the V flag is not set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exi...
BVS label Branch to the instruction at label if the V flag is set def BVS(self, params): """ BVS label Branch to the instruction at label if the V flag is set """ label = self.get_one_parameter(self.ONE_PARAMETER, params) self.check_arguments(label_exists=(lab...
Shows one entry per distinct metric name def get_queryset(self, request): """Shows one entry per distinct metric name""" queryset = super(MetricGroupAdmin, self).get_queryset(request) # poor-man's DISTINCT ON for Sqlite3 qs_values = queryset.values('id', 'name') # 2.7+ only :( ...
Updates all metrics with the same name def save_model(self, request, obj, form, change): """Updates all metrics with the same name""" like_metrics = self.model.objects.filter(name=obj.name) # 2.7+ only :( # = {key: form.cleaned_data[key] for key in form.changed_data} updates = {...
Return a list of the parsed code For each line, return a three-tuple containing: 1. The label 2. The instruction 3. Any arguments or parameters An element in the tuple may be None or '' if it did not find anything :param code: The code to parse :return: A list o...
Is the parameter a register in the form of 'R<d>', and if so is it within the bounds of registers defined Raises an exception if 1. The parameter is not in the form of 'R<d>' 2. <d> is outside the range of registers defined in the init value registers or _max_registers ...
Is the parameter an immediate in the form of '#<d>', Raises an exception if 1. The parameter is not in the form of '#<d>' :param arg: The parameter to check :return: The value of the immediate def check_immediate(self, arg): """ Is the parameter an immediate in the form...
Is the immediate within the unsigned value of 2**bit - 1 Raises an exception if 1. The immediate value is > 2**bit - 1 :param arg: The parameter to check :param bit: The number of bits to use in 2**bit :return: The value of the immediate def check_immediate_unsigned_value(self,...
Is the immediate within the range of [_min, _max] Raises an exception if 1. The immediate value is < _min or > _max :param arg: The parameter to check :param _max: The maximum value :param _min: The minimum value, optional, default is zero :return: The immediate value d...
Low registers are R0 - R7 def rule_low_registers(self, arg): """Low registers are R0 - R7""" r_num = self.check_register(arg) if r_num > 7: raise iarm.exceptions.RuleError( "Register {} is not a low register".format(arg))
Given a regex expression and the string with the paramers, either return a regex match object or raise an exception if the regex did not find a match :param regex_exp: :param parameters: :return: def get_parameters(self, regex_exp, parameters): """ Given a regex ...
Get three parameters from a given regex expression Raise an exception if more than three were found :param regex_exp: :param parameters: :return: def get_one_parameter(self, regex_exp, parameters): """ Get three parameters from a given regex expression Raise an...
Get two parameters from a given regex expression Raise an exception if more than two were found :param regex_exp: :param parameters: :return: def get_two_parameters(self, regex_exp, parameters): """ Get two parameters from a given regex expression Raise an exce...
Get three parameters from a given regex expression Raise an exception if more than three were found :param regex_exp: :param parameters: :return: def get_three_parameters(self, regex_exp, parameters): """ Get three parameters from a given regex expression Raise...
Set or clear flag in ASPR :param flag: The flag to set :param value: If value evaulates to true, it is set, cleared otherwise :return: def set_APSR_flag_to_value(self, flag, value): """ Set or clear flag in ASPR :param flag: The flag to set :param value: If value...
Raises an exception if the register is not a special register def rule_special_registers(self, arg): """Raises an exception if the register is not a special register""" # TODO is PSR supposed to be here? special_registers = "PSR APSR IPSR EPSR PRIMASK FAULTMASK BASEPRI CONTROL" if arg n...
Set C flag C flag is set if the unsigned number overflows This condition is obtained if: 1. In addition, the result is smaller than either of the operands 2. In subtraction, if the second operand is larger than the first This should not be used for shifting as each shift will ne...
Output version of gcdt tools and plugins. def version(): """Output version of gcdt tools and plugins.""" log.info('gcdt version %s' % __version__) tools = get_plugin_versions('gcdttool10') if tools: log.info('gcdt tools:') for p, v in tools.items(): log.info(' * %s version %...
Function decorator implementing retrying logic. delay: Sleep this many seconds * backoff * try number after failure backoff: Multiply delay by this factor after each failure exceptions: A tuple of exception classes; default (Exception,) hook: A function with the signature: (tries_remaining, exception, ...
Read environment from ENV and mangle it to a (lower case) representation Note: gcdt.utils get_env() is used in many cloudformation.py templates :return: Environment as lower case string (or None if not matched) def get_env(): """ Read environment from ENV and mangle it to a (lower case) representation ...
This assembles the tool context. Private members are preceded by a '_'. :param tool: :param command: :return: dictionary containing the gcdt tool context def get_context(awsclient, env, tool, command, arguments=None): """This assembles the tool context. Private members are preceded by a '_'. :par...
Extract the first argument from arguments parsed by docopt. :param arguments parsed by docopt: :return: command def get_command(arguments): """Extract the first argument from arguments parsed by docopt. :param arguments parsed by docopt: :return: command """ return [k for k, v in argument...
Check whether a newer gcdt is available and output a warning. def check_gcdt_update(): """Check whether a newer gcdt is available and output a warning. """ try: inst_version, latest_version = get_package_versions('gcdt') if inst_version < latest_version: log.warn('Please consid...