Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"No ECS services found in cluster: {}".format(
cluster))
# should we filter the number of services to take into account?
if service_pattern:
services = filter_services(services=services,
pattern=service_pattern)
if not services:
raise FailedActivity(
"No ECS services matching pattern: {}".format(
service_pattern))
service = random.choice(services)
service = service.rsplit("/", 1)[1]
logger.debug("Updating ECS service: {}".format(service))
client.update_service(cluster=cluster, service=service,
desiredCount=0,
deploymentConfiguration={
'maximumPercent': 100,
'minimumHealthyPercent': 0
})
logger.debug("Deleting ECS service: {}".format(service))
return client.delete_service(cluster=cluster, service=service)
for page in page_iterator:
asg_descrs['AutoScalingGroups'].extend(page['AutoScalingGroups'])
filter_set = set(map(lambda x: "=".join([x['Key'], x['Value']]), tags))
group_sets = list(map(lambda g: {
'Name': g['AutoScalingGroupName'],
'Tags': set(map(
lambda t: "=".join([t['Key'], t['Value']]), g['Tags'])
)}, asg_descrs['AutoScalingGroups']))
filtered_groups = [g['Name']
for g in group_sets if filter_set.issubset(g['Tags'])]
logger.debug("filtered groups: {}".format(filtered_groups))
if filtered_groups:
groups_descr = client.describe_auto_scaling_groups(
AutoScalingGroupNames=filtered_groups)
return groups_descr
else:
raise FailedActivity(
"No auto-scaling groups matched the tags provided")
def put(self, method, data, headers=None, params=None):
logger.debug("PUT: " + self.endpoint + method)
logger.debug("Headers:")
logger.debug(headers)
logger.debug("Params:")
logger.debug(params)
logger.debug("Body:")
logger.debug(data)
r = self.session.put(self.endpoint + method, data=json.dumps(data), headers=headers, params=params)
logger.debug("Response:")
logger.debug(r)
logger.debug("Response Body:")
logger.debug(r.text)
if r.status_code != 200:
r.reason = r.text
r.raise_for_status()
return r
def _force_reset_uiautomator_v2(self):
brand = self.shell("getprop ro.product.brand").output.strip()
logger.debug("Device: %s, %s", brand, self.serial)
package_name = "com.github.uiautomator"
first_killed = False
# logger.debug("app-start com.github.uiautomator")
self.uiautomator.stop()
self.shell(["am", "force-stop", package_name])
logger.debug("stop app: %s", package_name)
# self._start_uiautomator_app()
# self.uiautomator.start()
# stop command which launched with uiautomator 1.0
# eg: adb shell uiautomator runtest androidUiAutomator.jar
logger.debug("kill process(ps): uiautomator")
self._kill_process_by_name("uiautomator")
def post(self, method, data, headers=None, params=None):
logger.debug("POST: " + self.endpoint + method)
logger.debug("Headers:")
logger.debug(headers)
logger.debug("Params:")
logger.debug(params)
logger.debug("Body:")
logger.debug(data)
r = self.session.post(self.endpoint + method, data=json.dumps(data), headers=headers, params=params)
logger.debug("Response:")
logger.debug(r)
logger.debug("Response Body:")
logger.debug(r.text)
if r.status_code != 200:
r.reason = r.text
r.raise_for_status()
return r
log_format: str = "string", settings: str = CHAOSTOOLKIT_CONFIG_PATH):
if no_log_file:
configure_logger(
verbose=verbose, log_format=log_format,
context_id=str(uuid.uuid4()))
else:
configure_logger(
verbose=verbose, log_file=log_file, log_format=log_format,
context_id=str(uuid.uuid4()))
subcommand = ctx.invoked_subcommand
# make it nicer for going through the log file
logger.debug("#" * 79)
logger.debug("Running command '{}'".format(subcommand))
ctx.obj = {}
ctx.obj["settings_path"] = click.format_filename(settings)
logger.debug("Using settings file '{}'".format(ctx.obj["settings_path"]))
if not no_version_check:
check_newer_version(command=subcommand)
if change_dir:
logger.warning("Moving to {d}".format(d=change_dir))
os.chdir(change_dir)
if no_recursion:
max_depth = 0
elif max_depth is None:
max_depth = float('inf')
to_upload = get_local_songs(input_paths, filters=filters, max_depth=max_depth)
to_upload.sort()
if not to_upload:
logger.info("No songs to upload")
elif dry_run:
logger.info(f"Found {len(to_upload)} songs to upload")
if logger.level <= 10:
for song in to_upload:
logger.debug(song)
else:
upload_songs(
mm,
to_upload,
album_art=album_art,
no_sample=no_sample,
delete_on_success=delete_on_success
)
mm.logout()
logger.info("All done!")
run = {
"activity": activity.copy(),
"output": None
}
result = None
interrupted = False
try:
# only run the activity itself when not in dry-mode
if not dry:
result = run_activity(activity, configuration, secrets)
run["output"] = result
run["status"] = "succeeded"
if result is not None:
logger.debug(" => succeeded with '{r}'".format(r=result))
else:
logger.debug(" => succeeded without any result value")
except ActivityFailed as x:
error_msg = str(x)
run["status"] = "failed"
run["output"] = result
run["exception"] = traceback.format_exception(type(x), x, None)
logger.error(" => failed: {x}".format(x=error_msg))
finally:
# capture the end time before we pause
end = datetime.utcnow()
run["start"] = start.isoformat()
run["end"] = end.isoformat()
run["duration"] = (end - start).total_seconds()
pause_after = pauses.get("after")
def scrape(self, bestmatch=True, tries_remaining=5):
""" Search and scrape YouTube to return a list of matching videos. """
# prevents an infinite loop but allows for a few retries
if tries_remaining == 0:
log.debug("No tries left. I quit.")
return
search_url = generate_search_url(self.search_query)
log.debug("Opening URL: {0}".format(search_url))
item = self._fetch_response(search_url).read()
items_parse = BeautifulSoup(item, "html.parser")
videos = []
for x in items_parse.find_all(
"div", {"class": "yt-lockup-dismissable yt-uix-tile"}
):
if not is_video(x):
continue
y = x.find("div", class_="yt-lockup-content")
link = y.find("a")["href"][-11:]
title = y.find("a")["title"]
def get_background_pools(experiment: Experiment) -> ThreadPoolExecutor:
"""
Create a pool for background activities. The pool is as big as the number
of declared background activities. If none are declared, returned `None`.
"""
method = experiment.get("method", [])
rollbacks = experiment.get("rollbacks", [])
activity_background_count = 0
for activity in method:
if activity and activity.get("background"):
activity_background_count = activity_background_count + 1
activity_pool = None
if activity_background_count:
logger.debug(
"{c} activities will be run in the background".format(
c=activity_background_count))
activity_pool = ThreadPoolExecutor(activity_background_count)
rollback_background_pool = 0
for activity in rollbacks:
if activity and activity.get("background"):
rollback_background_pool = rollback_background_pool + 1
rollback_pool = None
if rollback_background_pool:
logger.debug(
"{c} rollbacks will be run in the background".format(
c=rollback_background_pool))
rollback_pool = ThreadPoolExecutor(rollback_background_pool)