PEP-8 compliance

This commit is contained in:
Raylan 2025-01-23 14:58:47 -03:00
parent 8c96d7a5f5
commit 5c6ec7ff86
2 changed files with 5 additions and 5 deletions

View File

@ -14,13 +14,13 @@ def enter_namespace(namespace, namespace_pid):
namespace_dir = f'{NETNS_RUN_DIR}/{namespace}' namespace_dir = f'{NETNS_RUN_DIR}/{namespace}'
else: else:
namespace_dir = f'/proc/{namespace_pid}/ns/net' namespace_dir = f'/proc/{namespace_pid}/ns/net'
if not os.path.exists(namespace_dir): if not os.path.exists(namespace_dir):
raise Fatal('The namespace %r does not exists.' % namespace_dir) raise Fatal('The namespace %r does not exists.' % namespace_dir)
debug2('loading libc') debug2('loading libc')
libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True) libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True)
default_errcheck = libc.setns.errcheck default_errcheck = libc.setns.errcheck
def errcheck(ret, *args): def errcheck(ret, *args):
@ -29,8 +29,8 @@ def enter_namespace(namespace, namespace_pid):
raise Fatal(e, os.strerror(e)) raise Fatal(e, os.strerror(e))
if default_errcheck: if default_errcheck:
return default_errcheck(ret, *args) return default_errcheck(ret, *args)
libc.setns.errcheck = errcheck # type: ignore libc.setns.errcheck = errcheck # type: ignore
debug1('Entering namespace %r' % namespace_dir) debug1('Entering namespace %r' % namespace_dir)

View File

@ -189,7 +189,7 @@ def test_parse_namespace():
'@my.long_namespace.with.multiple.dots', '@my.long_namespace.with.multiple.dots',
'my.Namespace.With.Mixed.Case', 'my.Namespace.With.Mixed.Case',
] ]
for namespace in valid_namespaces: for namespace in valid_namespaces:
assert sshuttle.options.parse_namespace(namespace) == namespace assert sshuttle.options.parse_namespace(namespace) == namespace