Skip to content

Commit a54c7ce

Browse files
committed
pep8 and flake
1 parent e20c963 commit a54c7ce

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

stormdb/access.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def _get_login_code(self):
106106
try:
107107
with open(os.path.expanduser(self._stormdblogin), 'r') as fid:
108108
if self._verbose:
109-
print('Reading login credentials from ' +
110-
self._stormdblogin)
109+
print('Reading login credentials from {:s}'.format(
110+
self._stormdblogin))
111111
self._login_code = fid.readline()
112112
except IOError:
113113
print('Login credentials not found, please enter them here')
@@ -193,7 +193,7 @@ def _send_request(self, url, verbose=None):
193193

194194
try:
195195
req = requests.get(full_url)
196-
except:
196+
except ConnectionError:
197197
print('hyades00 is not responding, it may be down.')
198198
print('Contact a system administrator for confirmation.')
199199
raise
@@ -240,12 +240,12 @@ def get_subjects(self,
240240
raise ValueError(
241241
'You can only specify a modality OR a series, not both.')
242242
type_err = '{} must be a string, not {}.'
243-
if (has_modality is not None
244-
and not isinstance(has_modality, string_types)):
243+
if (has_modality is not None and not
244+
isinstance(has_modality, string_types)):
245245
raise ValueError(
246246
type_err.format('has_modality', type(has_modality)))
247-
if (has_series is not None
248-
and not isinstance(has_series, string_types)):
247+
if (has_series is not None and not
248+
isinstance(has_series, string_types)):
249249
raise ValueError(type_err.format('has_series', type(has_series)))
250250

251251
# using 'subjecs' here would return only numeric ID, not code
@@ -278,8 +278,8 @@ def get_subjects(self,
278278
subj_list = [
279279
ser['subjectcode'] for ser in all_series
280280
if ser['subjectcode'] not in used and (
281-
used.append(ser['subjectcode']) or True)
282-
and ser['subjectcode'] in subj_list
281+
used.append(ser['subjectcode']) or True) and (
282+
ser['subjectcode'] in subj_list)
283283
]
284284
# The following also works, but is slower?
285285
# pop_inds = []
@@ -297,8 +297,8 @@ def get_subjects(self,
297297
subj_list = [
298298
ser['subjectcode'] for ser in all_series
299299
if ser['subjectcode'] not in used and (
300-
used.append(ser['subjectcode']) or True)
301-
and ser['subjectcode'] in subj_list
300+
used.append(ser['subjectcode']) or True) and (
301+
ser['subjectcode'] in subj_list)
302302
]
303303

304304
return (subj_list)
@@ -618,7 +618,7 @@ def filter_series(self,
618618
format(study_metas['name'],
619619
study_metas['comparison'],
620620
study_metas['value'])
621-
except:
621+
except KeyError:
622622
print('Problem with study_metas:')
623623
print(study_metas)
624624
raise
@@ -653,7 +653,7 @@ def filter_series(self,
653653
key_val_pair[1].sort(key=lambda x: os.path.splitext(x)[0])
654654

655655
elif 'path' in key_val_pair[0]:
656-
m = re.search('\d{3}\.(.+?)/files', key_val_pair[1])
656+
m = re.search(r'\d{3}\.(.+?)/files', key_val_pair[1])
657657
info.append(['seriename', m.group(1)])
658658
info.append(key_val_pair)
659659
info_dict = {key: value for (key, value) in info}
@@ -664,8 +664,8 @@ def filter_series(self,
664664
study_date_range = [study_date_range, study_date_range]
665665
info_dict_list = [
666666
s for s in info_dict_list
667-
if s['study'][:8] >= study_date_range[0]
668-
and s['study'][:8] <= study_date_range[1]
667+
if s['study'][:8] >= study_date_range[0] and (
668+
s['study'][:8] <= study_date_range[1])
669669
]
670670
return (info_dict_list)
671671

stormdb/cluster.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,19 @@ def get_memlimit_per_process(self, queue):
103103
if queue not in self.queues:
104104
raise ValueError('Unknown queue: {:s}'.format(queue))
105105

106-
lim = self._query('qconf -sq ' + queue +
107-
'| grep h_vmem | awk {\'print $2\'}')[0]
106+
lim = self._query('qconf -sq ' + queue + (
107+
'| grep h_vmem | awk {\'print $2\'}'))[0]
108108

109-
_, lim_int, lim_units = re.split('(\d+)', lim)
109+
_, lim_int, lim_units = re.split(r'(\d+)', lim)
110110
assert isinstance(int(lim_int), int)
111111
assert isinstance(lim_units, string_types)
112112

113113
return (lim)
114114

115115
def _check_parallel_env(self, queue, pe_name):
116116
"""Check that a PE is in the pe_list for a given queue"""
117-
pes = self._query('qconf -sq ' + queue +
118-
'| grep pe_list')[0] # just one line
117+
pes = self._query('qconf -sq ' + queue + (
118+
'| grep pe_list'))[0] # just one line
119119
pe_list = pes.split()[1:]
120120
if pe_name not in pe_list:
121121
raise ValueError('Queue \'{0}\' does not support the \'{1}\' '
@@ -238,14 +238,14 @@ def __init__(self,
238238
'Maximum number of parallel threads is one (1) when total '
239239
'memory consumption is specified.')
240240
# XXX would be nice with some sanity checking here...
241-
_, totmem, totmem_unit = re.split('(\d+)', self.total_memory)
242-
_, memlim, memlim_unit = re.split('(\d+)', h_vmem)
241+
_, totmem, totmem_unit = re.split(r'(\d+)', self.total_memory)
242+
_, memlim, memlim_unit = re.split(r'(\d+)', h_vmem)
243243

244244
if totmem_unit != memlim_unit:
245245
units = dict(k=1e3, m=1e6, g=1e9, t=1e12)
246246
try:
247247
ratio = units[totmem_unit.lower()] /\
248-
units[memlim_unit.lower()]
248+
units[memlim_unit.lower()]
249249
except KeyError:
250250
raise ValueError('Something is wrong with the memory units'
251251
', likely {:s}'.format(self.total_memory))
@@ -310,9 +310,9 @@ def _initialise_cmd(self, value):
310310
def _create_qsub_script(self, job_name, cwd_flag, opt_threaded_flag,
311311
opt_h_vmem_flag, log_name_prefix):
312312
"""All variables should be defined"""
313-
if (self.cmd is None or self.queue is None or job_name is None
314-
or cwd_flag is None or opt_threaded_flag is None
315-
or opt_h_vmem_flag is None):
313+
if (self.cmd is None or self.queue is None or job_name is None or
314+
cwd_flag is None or opt_threaded_flag is None or
315+
opt_h_vmem_flag is None):
316316
raise ValueError('This should not happen, please report an Issue!')
317317

318318
self._qsub_script =\
@@ -367,7 +367,7 @@ def submit(self, fake=False, sh_file='~/submit_job.sh'):
367367
else:
368368
# py2-3 safety
369369
output = output.decode('ascii', 'ignore').rstrip()
370-
m = re.search('(\d+)', output)
370+
m = re.search(r'(\d+)', output)
371371
self._jobid = m.group(1)
372372
if self._cleanup_qsub_job:
373373
self._delete_qsub_job()
@@ -387,8 +387,8 @@ def _check_status(self):
387387
' | awk \'{print $5, $8}\'')[0] # ONLY
388388

389389
if len(output) == 0:
390-
if (self._submitted and not self._running and not self._completed
391-
and not self._waiting):
390+
if (self._submitted and not self._running and not
391+
self._completed and not self._waiting):
392392
self._status_msg = ('Submission failed, see log for'
393393
' output errors!')
394394
elif self._submitted and not self._completed:
@@ -485,8 +485,8 @@ def verbose(self, value):
485485
def kill(self, jobid=None):
486486
"""Kill (delete) all the jobs in the batch."""
487487
for job in self._joblist:
488-
if (jobid is None
489-
or (jobid is not None and int(job._jobid) == int(jobid))):
488+
if (jobid is None or (
489+
jobid is not None and int(job._jobid) == int(jobid))):
490490
job.kill()
491491

492492
def build_cmd(self):

0 commit comments

Comments
 (0)