Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_config_from_file(self, key, attr, value, tmpdir):
config_file = tmpdir.join("config.yaml")
with config_file.open("w") as fobj:
pyaml.dump({key: value}, fobj, safe=True, default_style='"')
config = Configuration(["--config-file", config_file.strpath])
assert getattr(config, attr) == value
def auth(self):
status = True
manager = Manager.objects.get(name=self.metadata['cloud_endpoint'])
if not os.path.isdir(self.metadata['template_path']):
status = False
try:
config_file, filename = tempfile.mkstemp()
config_content = {
'clouds': {self.name: manager.metadata}
}
os.write(config_file, pyaml.dump(config_content).encode())
os.close(config_file)
self.cloud = os_client_config.config \
.OpenStackConfig(config_files=[filename]) \
.get_one_cloud(cloud=self.name)
os.remove(filename)
self.api = self._get_client('orchestration')
except ConnectFailure as exception:
logger.error(exception)
status = False
return status
'contexts': [{
'context': {
'cluster': self.name,
'user': self.name,
},
'name': self.name,
}],
'current-context': self.name,
'kind': 'Config',
'preferences': {},
'users': [{
'name': self.name,
'user': self.metadata['user']
}]
}
os.write(config_file, pyaml.dump(config_content).encode())
os.close(config_file)
self.config_wrapper = pykube.KubeConfig.from_file(filename)
os.remove(filename)
self.api = pykube.HTTPClient(self.config_wrapper)
pods = pykube.Pod.objects(self.api).filter(namespace="kube-system")
for pod in pods:
pass
except URLError as exception:
logger.error(exception)
status = False
except ConnectionError as exception:
logger.error(exception)
status = False
return status
# in messages
msg = msg.replace('Explanation:', '\n Explanation:')
# The settings will tell us if we should show all details or not
# The message is part of the details, so if it's already being shown
# do not show it again
details = None
if self.suite.config.pr_comment_report.get('show_details', False):
result_details = dict(result.details)
if show_message:
del result_details['message']
if not result_details:
details = None
else:
details = PRCommentReport._increase_readability(
pyaml.dump(result_details)
)
msg = '\n {}'.format(msg) if msg else ''
details = '\n {}'.format(details) if details else ''
return '- **{check_type}**{msg}{details}'.format(
check_type=result.config.check_type, msg=msg, details=details
)
def _dump_yaml():
yaml_str = ""
if len(_secrets) > 0:
yaml_str = pyaml.dump(_secrets, string_val_style="plain")
yaml_str = "%s\n---\n" % yaml_str
yaml_str = yaml_str + pyaml.dump(yaml(), string_val_style="plain")
print(yaml_str)
original=raw('HiC_EL.bed'),
processed=proc('HiC-' + domain + '.bigBed'),
script=script,
description='Hi-C domain [%s; embryo]' % domain,
label='Hi-C domain [%s; embryo]' % domain,
genome='dm3',
url='url to supplemental data',
type='bigbed',
trackinfo={
'visibility': 'dense',
'tracktype': 'bigBed 3',
},
)
)
pyaml.dump(d, open('metadata.yaml', 'w'), vspacing=[1,1])
def transform(self, app_config):
converted_app_config = self._spec_factory.transform(app_config, strip_defaults=True)
return pyaml.dump(converted_app_config)
body = webmention.body
metadata = webmention.__dict__
del metadata['summary']
del metadata['body']
metadata['source'] = metadata.pop('url') # jekyll reservers the '.url'
try: metadata['author_url'] = metadata['author'].pop('url')
except: pass
try: metadata['author_name'] = metadata['author'].pop('name')
except: pass
try: metadata['author_image'] = metadata['author'].pop('photo')
except: pass
del metadata['author'] # jekyll doesn't support yaml trees
metadata['target'] = request.form['target']
wm_file = u'---\n%s---\n%s' % (pyaml.dump(metadata), body)
if u'…' in path:
return 'not ok'
# commit the webmention file at the github repo
r = requests.put(
'https://api.github.com/repos/' + repo + '/contents/_webmentions/' + path + '/' + hashlib.md5(metadata['source']).hexdigest() + '.md',
params={'access_token': token},
data=json.dumps({
'content': base64.b64encode(wm_file.encode('utf-8')),
'message': 'webmention from ' + source,
'committer': {
'name': 'Jekmention',
'email': 'jekmention@jekmentions.alhur.es'
}
})
'contexts': [{
'context': {
'cluster': self.name,
'user': self.name,
},
'name': self.name,
}],
'current-context': self.name,
'kind': 'Config',
'preferences': {},
'users': [{
'name': self.name,
'user': self.metadata['user']
}]
}
return pyaml.dump(config_content)