Skip to content

Commit c8d6482

Browse files
committed
remove trailing lines
1 parent 4f80263 commit c8d6482

File tree

7 files changed

+90
-90
lines changed

7 files changed

+90
-90
lines changed

cpuset/commands/proc.py

+32-32
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
from cpuset import cset
2828
from cpuset.util import *
2929
from cpuset.commands.common import *
30-
try: from cpuset.commands import set
30+
try: from cpuset.commands import set
3131
except SyntaxError:
3232
raise
33-
except:
33+
except:
3434
pass
3535

3636
global log
@@ -57,7 +57,7 @@
5757
and specifying the cpuset that the process is to be created in.
5858
5959
For example:
60-
# cset proc --set=blazing_cpuset --exec /usr/bin/fast_code
60+
# cset proc --set=blazing_cpuset --exec /usr/bin/fast_code
6161
This command will execute the /usr/bin/fast_code program
6262
on the "blazing_cpuset" cpuset.
6363
@@ -126,7 +126,7 @@
126126
kernel threads will be added to the move. Unbound kernel threads
127127
are those that can run on any CPU. If you also specify the
128128
--force switch, then all tasks, kernel or not, bound or not,
129-
will be moved.
129+
will be moved.
130130
131131
CAUTION: Please be cautious with the --force switch, since moving
132132
a kernel thread that is bound to a specific CPU to a cpuset that
@@ -207,14 +207,14 @@ def func(parser, options, args):
207207

208208
cset.rescan()
209209

210-
tset = None
210+
tset = None
211211
if options.list or options.exc:
212212
if options.set:
213213
tset = cset.unique_set(options.set)
214214
elif options.toset:
215215
tset = cset.unique_set(options.toset)
216216
elif len(args) > 0:
217-
if options.exc:
217+
if options.exc:
218218
tset = cset.unique_set(args[0])
219219
del args[0]
220220
else:
@@ -270,7 +270,7 @@ def func(parser, options, args):
270270
set.active(tset)
271271
# next, if there is a pidspec, move just that
272272
if options.pid:
273-
if options.fromset and not options.force:
273+
if options.fromset and not options.force:
274274
fset = cset.unique_set(options.fromset)
275275
elif options.toset and options.set:
276276
fset = cset.unique_set(options.set)
@@ -295,15 +295,15 @@ def func(parser, options, args):
295295
raise CpusetException("origination cpuset not specified")
296296
nt = len(fset.tasks)
297297
if nt == 0:
298-
raise CpusetException('no tasks to move from cpuset "%s"'
298+
raise CpusetException('no tasks to move from cpuset "%s"'
299299
% fset.path)
300300
if options.move:
301-
log.info('moving all tasks from %s to %s',
301+
log.info('moving all tasks from %s to %s',
302302
fset.name, tset.path)
303303
selective_move(fset, tset, None, options.kthread, options.force,
304304
options.threads)
305305
else:
306-
log.info('moving all kernel threads from %s to %s',
306+
log.info('moving all kernel threads from %s to %s',
307307
fset.path, tset.path)
308308
# this is a -k "move", so only move kernel threads
309309
pids = []
@@ -321,12 +321,12 @@ def list_sets(args):
321321
log.debug("entering list_sets, args=%s", args)
322322
l = []
323323
if isinstance(args, list):
324-
for s in args:
324+
for s in args:
325325
if isstr(s):
326326
l.extend(cset.find_sets(s))
327327
elif not isinstance(s, cset.CpuSet):
328328
raise CpusetException(
329-
'list_sets() args=%s, of which "%s" not a string or CpuSet'
329+
'list_sets() args=%s, of which "%s" not a string or CpuSet'
330330
% (args, s))
331331
else:
332332
l.append(s)
@@ -350,7 +350,7 @@ def list_sets(args):
350350
log.info(cset.summary(s))
351351

352352
def move(fromset, toset, plist=None, verb=None, force=None):
353-
log.debug('entering move, fromset=%s toset=%s list=%s force=%s verb=%s',
353+
log.debug('entering move, fromset=%s toset=%s list=%s force=%s verb=%s',
354354
fromset, toset, plist, force, verb)
355355
if isstr(fromset):
356356
fset = cset.unique_set(fromset)
@@ -368,15 +368,15 @@ def move(fromset, toset, plist=None, verb=None, force=None):
368368
tset = toset
369369
if plist == None:
370370
log.debug('moving default of all processes')
371-
if tset != fset and not force:
371+
if tset != fset and not force:
372372
plist = fset.tasks
373373
else:
374374
raise CpusetException(
375375
"cannot move tasks into their origination cpuset")
376376
output = 0
377-
if verb:
377+
if verb:
378378
output = verb
379-
elif verbose:
379+
elif verbose:
380380
output = verbose
381381
if output:
382382
l = []
@@ -410,7 +410,7 @@ def selective_move(fset, tset, plist=None, kthread=None, force=None, threads=Non
410410
ktskb = 0
411411
sstsk = 0
412412
target = cset.unique_set(tset)
413-
if fset:
413+
if fset:
414414
fset = cset.unique_set(fset)
415415
if fset == target and not force:
416416
raise CpusetException(
@@ -426,7 +426,7 @@ def selective_move(fset, tset, plist=None, kthread=None, force=None, threads=Non
426426
# kernel threads do not have an excutable image
427427
os.readlink('/proc/'+task+'/exe')
428428
autsk += 1
429-
if fset and not force:
429+
if fset and not force:
430430
try:
431431
task_check.index(task)
432432
tasks.append(task)
@@ -440,9 +440,9 @@ def selective_move(fset, tset, plist=None, kthread=None, force=None, threads=Non
440440
if thread != task:
441441
log.debug(' adding thread %s', thread)
442442
tasks.append(thread)
443-
utsk += 1
443+
utsk += 1
444444
except ValueError:
445-
log.debug(' task %s not running in %s, skipped',
445+
log.debug(' task %s not running in %s, skipped',
446446
task, fset.name)
447447
utsknr += 1
448448
else:
@@ -459,11 +459,11 @@ def selective_move(fset, tset, plist=None, kthread=None, force=None, threads=Non
459459
# this is in try because the task may not exist by the
460460
# time we do this, in that case, just ignore it
461461
if kthread:
462-
if force:
462+
if force:
463463
tasks.append(task)
464464
ktsk += 1
465465
else:
466-
if is_unbound(task):
466+
if is_unbound(task):
467467
tasks.append(task)
468468
ktsk += 1
469469
elif cset.lookup_task_from_cpusets(task) == target.path:
@@ -480,7 +480,7 @@ def selective_move(fset, tset, plist=None, kthread=None, force=None, threads=Non
480480
ktsknr += 1
481481
# ok, move 'em
482482
log.debug('moving %d tasks to %s ...', len(tasks), tset.name)
483-
if len(tasks) == 0:
483+
if len(tasks) == 0:
484484
log.info('**> no task matched move criteria')
485485
if sstsk > 0:
486486
raise CpusetException('same source/destination cpuset, use --force if ok')
@@ -535,8 +535,8 @@ def run(tset, args, usr_par=None, grp_par=None):
535535
log.debug('entering run, set=%s args=%s ', s.path, args)
536536
set.active(s)
537537
# check user
538-
if usr_par:
539-
try:
538+
if usr_par:
539+
try:
540540
user = pwd.getpwnam(usr_par)[2]
541541
except KeyError:
542542
try:
@@ -562,34 +562,34 @@ def run(tset, args, usr_par=None, grp_par=None):
562562
pass # just forget it
563563
# move myself into target cpuset and exec child
564564
move_pidspec(str(os.getpid()), s)
565-
log.info('--> last message, executed args into cpuset "%s", new pid is: %s',
566-
s.path, os.getpid())
565+
log.info('--> last message, executed args into cpuset "%s", new pid is: %s',
566+
s.path, os.getpid())
567567
# change user and group before exec
568568
if grp_par: os.setgid(group)
569-
if usr_par:
569+
if usr_par:
570570
os.setuid(user)
571571
os.environ["LOGNAME"] = usr_par
572572
os.environ["USERNAME"] = usr_par
573573
os.environ["USER"] = usr_par
574574
os.execvp(args[0], args)
575575

576576
def is_unbound(proc):
577-
# FIXME: popen is slow...
577+
# FIXME: popen is slow...
578578
# --> use /proc/<pid>/status -> Cpus_allowed
579579
# int(line.replace(',',''), 16)
580580
# note: delete leading zeros to compare to allcpumask
581581
line = os.popen('/usr/bin/taskset -p ' + str(proc) +' 2>/dev/null', 'r').readline()
582582
aff = line.split()[-1]
583-
log.debug('is_unbound, proc=%s aff=%s allcpumask=%s',
583+
log.debug('is_unbound, proc=%s aff=%s allcpumask=%s',
584584
proc, aff, cset.allcpumask)
585585
if aff == cset.allcpumask: return True
586586
return False
587587

588588
def pidspec_to_list(pidspec, fset=None, threads=False):
589589
"""create a list of process ids out of a pidspec"""
590-
log.debug('entering pidspecToList, pidspec=%s fset=%s threads=%s',
590+
log.debug('entering pidspecToList, pidspec=%s fset=%s threads=%s',
591591
pidspec, fset, threads)
592-
if fset:
592+
if fset:
593593
if isstr(fset): fset = cset.unique_set(fset)
594594
elif not isinstance(fset, cset.CpuSet):
595595
raise CpusetException("passed fset=%s, which is not a string or CpuSet" % fset)

cpuset/commands/set.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
try: from cpuset.commands import proc
3131
except SyntaxError:
3232
raise
33-
except:
33+
except:
3434
pass
3535

3636
global log
@@ -151,7 +151,7 @@
151151
help = 'do things recursively, use with --list and --destroy',
152152
action = 'store_true'),
153153
make_option('--force',
154-
help = 'force recursive deletion even if processes are running '
154+
help = 'force recursive deletion even if processes are running '
155155
'in those cpusets (they will be moved to parent cpusets)',
156156
action = 'store_true'),
157157
make_option('-x', '--usehex',
@@ -254,7 +254,7 @@ def destroy_sets(sets, recurse=False, force=False):
254254
nl.append(sets)
255255
# check that sets passed are ok, will raise if one is bad
256256
sl2 = []
257-
for s in nl:
257+
for s in nl:
258258
st = cset.unique_set(s)
259259
sl2.append(st)
260260
if len(st.subsets) > 0:
@@ -291,7 +291,7 @@ def destroy(name):
291291
set = cset.unique_set(name)
292292
elif not isinstance(name, cset.CpuSet):
293293
raise CpusetException(
294-
"passed name=%s, which is not a string or CpuSet" % name)
294+
"passed name=%s, which is not a string or CpuSet" % name)
295295
else:
296296
set = name
297297
tsks = set.tasks
@@ -361,7 +361,7 @@ def create_from_options(options, args):
361361
mspec = None
362362
cx = None
363363
mx = None
364-
if options.cpu:
364+
if options.cpu:
365365
cset.cpuspec_check(options.cpu)
366366
cspec = options.cpu
367367
if options.mem:
@@ -385,11 +385,11 @@ def create(name, cpuspec, memspec, cx, mx):
385385
try:
386386
cset.unique_set(name)
387387
except CpusetNotFound:
388-
pass
388+
pass
389389
except:
390390
raise CpusetException('cpuset "%s" not unique, please specify by path' % name)
391391
else:
392-
raise CpusetExists('attempt to create already existing set: "%s"' % name)
392+
raise CpusetExists('attempt to create already existing set: "%s"' % name)
393393
# FIXME: check if name is a path here
394394
os.mkdir(cset.CpuSet.basepath+'/'+name)
395395
# fixme: perhaps reparsing the all the sets is not so efficient...
@@ -405,7 +405,7 @@ def modify(name, cpuspec=None, memspec=None, cx=None, mx=None):
405405
nset = cset.unique_set(name)
406406
elif not isinstance(name, cset.CpuSet):
407407
raise CpusetException(
408-
"passed name=%s, which is not a string or CpuSet" % name)
408+
"passed name=%s, which is not a string or CpuSet" % name)
409409
else:
410410
nset = name
411411
log.debug('modifying cpuset "%s"', nset.name)
@@ -472,7 +472,7 @@ def set_details(name, indent=None, width=None, usehex=False):
472472
if config.mread:
473473
l.append(set.path)
474474
l2 = []
475-
for line in l:
475+
for line in l:
476476
l2.append(line.strip())
477477
return ';'.join(l2)
478478

cpuset/commands/shield.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from cpuset.util import *
3131
from cpuset import config
3232

33-
global log
33+
global log
3434
log = logging.getLogger('shield')
3535

3636
help = 'supercommand to set up and manage basic shielding'
@@ -143,14 +143,14 @@
143143
144144
You can adjust which CPUs are in the shielded cpuset by issuing
145145
the --cpu subcommand again anytime after the shield has been
146-
initialized.
146+
initialized.
147147
148148
For example if the original shield contained CPU0 and CPU1 in the
149149
system set and CPU2 and CPU3 in the user set, if you then issue
150150
the following command:
151-
151+
152152
# cset shield --cpu=1,2,3
153-
153+
154154
then that command will move CPU1 into the shielded "user" cpuset.
155155
Any processes or threads that were running on CPU1 that belonged
156156
to the unshielded "system" cpuset are migrated to CPU0 by the
@@ -225,10 +225,10 @@ def func(parser, options, args):
225225
if options.verbose: verbose = options.verbose
226226
cset.rescan()
227227

228-
if options.sysset:
228+
if options.sysset:
229229
global SYS_SET
230230
SYS_SET = options.sysset
231-
if options.userset:
231+
if options.userset:
232232
global USR_SET
233233
USR_SET = options.userset
234234

@@ -254,24 +254,24 @@ def func(parser, options, args):
254254
options.shield = True
255255
else:
256256
return
257-
258-
if options.reset:
257+
258+
if options.reset:
259259
reset_shield()
260260
return
261261

262-
if options.cpu:
262+
if options.cpu:
263263
make_shield(options.cpu, options.kthread)
264264
return
265265

266-
if options.kthread:
266+
if options.kthread:
267267
make_kthread(options.kthread)
268268
return
269269

270270
if options.exc:
271271
exec_args(args, options.user, options.group)
272272
# exec_args does not return...
273273

274-
if options.shield or options.unshield:
274+
if options.shield or options.unshield:
275275
shield_exists()
276276
if options.shield:
277277
smsg = 'shielding'
@@ -351,11 +351,11 @@ def reset_shield():
351351
log.info("--> deactivating/reseting shielding")
352352
shield_exists()
353353
tasks = cset.unique_set(USR_SET).tasks
354-
log.info('moving %s tasks from "%s" user set to root set...',
354+
log.info('moving %s tasks from "%s" user set to root set...',
355355
len(tasks), USR_SET)
356356
proc.move(USR_SET, 'root', None, verbose)
357357
tasks = cset.unique_set(SYS_SET).tasks
358-
log.info('moving %s tasks from "%s" system set to root set...',
358+
log.info('moving %s tasks from "%s" system set to root set...',
359359
len(tasks), SYS_SET)
360360
proc.move(SYS_SET, 'root', None, verbose)
361361
log.info('deleting "%s" and "%s" sets', USR_SET, SYS_SET)
@@ -434,7 +434,7 @@ def make_kthread(state):
434434
if state == 'on':
435435
log.info('--> activating kthread shielding')
436436
root_tasks = cset.unique_set('/').tasks
437-
log.debug('root set has %d tasks, checking for unbound',
437+
log.debug('root set has %d tasks, checking for unbound',
438438
len(root_tasks))
439439
tasks = []
440440
for task in root_tasks:

0 commit comments

Comments
 (0)