Skip to content

Commit

Permalink
Code cleanup: remove commented code and reformat try/except
Browse files Browse the repository at this point in the history
- Thanks to @jhamrick
  • Loading branch information
rkdarst committed Oct 7, 2018
1 parent 1700eea commit fd19a89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions nbgrader/converters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ def set_permissions(self, assignment_id, student_id):
os.chmod(os.path.join(dirname, filename), permissions)
# If groupshared, set dir permissions - see comment below.
if self.coursedir.groupshared and os.stat(dirname).st_uid == os.getuid():
#for subdirname in subdirnames:
# subdirname = os.path.join(dirname, subdirname)
try: os.chmod(dirname, (os.stat(dirname).st_mode|0o2770) & 0o2777)
except PermissionError: pass
try:
os.chmod(dirname, (os.stat(dirname).st_mode|0o2770) & 0o2777)
except PermissionError:
pass
# If groupshared, set write permissions on directories. Directories
# are created within ipython_genutils.path.ensure_dir_exists via
# nbconvert.writer, (unless there are supplementary files) with a
Expand All @@ -264,8 +264,10 @@ def set_permissions(self, assignment_id, student_id):
# Root may be created in this step, and is not included above.
rootdir = self.coursedir.format_path(self._output_directory, '.', '.')
# Add 2770 to existing dir permissions (don't unconditionally override)
try: os.chmod(rootdir, (os.stat(rootdir).st_mode|0o2770) & 0o2777)
except PermissionError: pass
try:
os.chmod(rootdir, (os.stat(rootdir).st_mode|0o2770) & 0o2777)
except PermissionError:
pass


def convert_single_notebook(self, notebook_filename):
Expand Down
6 changes: 4 additions & 2 deletions nbgrader/exchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ def do_copy(self, src, dest):
if self.coursedir.groupshared:
for dirname, _, filenames in os.walk(dest):
# dirs become ug+rwx
try: os.chmod(dirname, (os.stat(dirname).st_mode|0o2770) & 0o2777)
except PermissionError: pass
try:
os.chmod(dirname, (os.stat(dirname).st_mode|0o2770) & 0o2777)
except PermissionError:
pass
for filename in filenames:
filename = os.path.join(dirname, filename)
try: os.chmod(filename, (os.stat(filename).st_mode|0o660) & 0o777)
Expand Down

0 comments on commit fd19a89

Please sign in to comment.