Skip to content

Commit

Permalink
Ticket #216: fix floor division operators (#222)
Browse files Browse the repository at this point in the history
Fix for Python 3 support.

Originally from stanford-rc/shine@1e80cc3

Signed-off-by: Stephane Thiell <[email protected]>
  • Loading branch information
degremont authored Jul 26, 2024
1 parent e5b2611 commit fe19f16
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Shine/Commands/Fsck.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def action_start(self, node, action, comp):

def action_progress(self, node, action, comp, result):
self._comps[comp] = result.progress
self._current = sum(self._comps.values()) / len(self._comps)
self._current = sum(self._comps.values()) // len(self._comps)
header = self.command.NAME.capitalize()
sys.stdout.write("%s in progress: %d %%\r" % (header, self._current))
sys.stdout.flush()
Expand All @@ -75,7 +75,7 @@ def action_start(self, node, action, comp):

def action_progress(self, node, action, comp, result):
self._comps[comp] = result.progress
self._current = sum(self._comps.values()) / len(self._comps)
self._current = sum(self._comps.values()) // len(self._comps)
header = self.command.NAME.capitalize()
sys.stdout.write("%s in progress: %d %%\r" % (header, self._current))
sys.stdout.flush()
Expand Down
4 changes: 2 additions & 2 deletions lib/Shine/Commands/Tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _add_quota_tuning(cls, tunings, fs_conf):
tunings.create_parameter_alias("quota_btune_oss", path)

# Convert the values to the right units
quota_btune = str(int(quota_btune) * int(quota_bunit) / 100)
quota_btune = str(int(quota_btune) * int(quota_bunit) // 100)

# Create the quota tuning parameters with the right values
tunings.create_parameter('quota_btune_mds', quota_btune, ['mds'])
Expand Down Expand Up @@ -196,7 +196,7 @@ def _add_quota_tuning(cls, tunings, fs_conf):
tunings.create_parameter_alias("quota_itune_oss", path)

# Convert the values to the right units
quota_itune = str(int(quota_itune) * int(quota_iunit) / 100)
quota_itune = str(int(quota_itune) * int(quota_iunit) // 100)

# Create the quota tuning parameters with the right values
tunings.create_parameter('quota_itune_mds', quota_itune, ['mds'])
Expand Down
2 changes: 1 addition & 1 deletion lib/Shine/Lustre/Actions/Format.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _prepare_cmd(self):

# loop back devices
if not self.comp.dev_isblk:
command.append('--device-size=%d' % (self.comp.dev_size / 1024))
command.append('--device-size=%d' % (self.comp.dev_size // 1024))

command.append(self.comp.dev)

Expand Down
2 changes: 1 addition & 1 deletion lib/Shine/Lustre/Actions/Fsck.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, passid, current, total):
@property
def progress(self):
"""Current fsck command progression value, between 1 and 100."""
return ((self.pass_id - 1 + self.pass_progress) / self._NB_PASSES) * 100
return ((self.pass_id - 1 + self.pass_progress) // self._NB_PASSES) * 100

class Fsck(FSAction):
"""
Expand Down

0 comments on commit fe19f16

Please sign in to comment.