mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-05-08 18:14:28 +02:00
PEP-8 compliance
This commit is contained in:
parent
8c96d7a5f5
commit
5c6ec7ff86
@ -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)
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user