Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a108236a
authored
Nov 07, 2018
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freebsd: resolve flake8 warnings in FreeBSD specific files
parent
a0f8465b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
freebsd/_freebsdcontext.py
+16
-16
freebsd/ssh.py
+3
-2
No files found.
freebsd/_freebsdcontext.py
View file @
a108236a
...
@@ -7,19 +7,19 @@ from shutil import copy, rmtree, move
...
@@ -7,19 +7,19 @@ from shutil import copy, rmtree, move
import
subprocess
import
subprocess
import
sys
import
sys
system
=
platform
.
system
()
system
=
platform
.
system
()
# noqa
working_directory
=
sys
.
path
[
0
]
working_directory
=
sys
.
path
[
0
]
# noqa
try
:
try
:
# noqa
# load virtio console driver, the device is /dev/ttyV0.1
# load virtio console driver, the device is /dev/ttyV0.1
# noqa
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'virtio_console'
))
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'virtio_console'
))
# noqa
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'smbfs'
))
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'smbfs'
))
# noqa
chdir
(
working_directory
)
chdir
(
working_directory
)
# noqa
subprocess
.
call
(
subprocess
.
call
(
# noqa
(
'/usr/local/bin/pip'
,
'install'
,
'-r'
,
'requirements.txt'
))
(
'/usr/local/bin/pip'
,
'install'
,
'-r'
,
'requirements.txt'
))
# noqa
copy
(
"/root/agent/misc/vm_renewal"
,
"/usr/local/bin/"
)
copy
(
"/root/agent/misc/vm_renewal"
,
"/usr/local/bin/"
)
# noqa
except
:
except
Exception
:
# noqa
pass
# hope it works
pass
# hope it works
# noqa
import
logging
import
logging
...
@@ -109,7 +109,7 @@ class Context(BaseContext):
...
@@ -109,7 +109,7 @@ class Context(BaseContext):
Context
.
_freebsd_set_time
(
float
(
time
))
Context
.
_freebsd_set_time
(
float
(
time
))
try
:
try
:
subprocess
.
call
([
'/usr/sbin/service'
'ntpd'
,
'onerestart'
])
subprocess
.
call
([
'/usr/sbin/service'
'ntpd'
,
'onerestart'
])
except
:
except
Exception
:
pass
pass
@staticmethod
@staticmethod
...
@@ -152,7 +152,7 @@ class Context(BaseContext):
...
@@ -152,7 +152,7 @@ class Context(BaseContext):
for
line
in
f
.
readlines
():
for
line
in
f
.
readlines
():
try
:
try
:
retval
.
append
(
PubKey
.
from_str
(
line
))
retval
.
append
(
PubKey
.
from_str
(
line
))
except
:
except
Exception
:
logger
.
exception
(
u'Invalid ssh key: '
)
logger
.
exception
(
u'Invalid ssh key: '
)
except
IOError
:
except
IOError
:
pass
pass
...
@@ -177,7 +177,7 @@ class Context(BaseContext):
...
@@ -177,7 +177,7 @@ class Context(BaseContext):
p
=
PubKey
.
from_str
(
key
)
p
=
PubKey
.
from_str
(
key
)
if
p
not
in
new_keys
:
if
p
not
in
new_keys
:
new_keys
.
append
(
p
)
new_keys
.
append
(
p
)
except
:
except
Exception
:
logger
.
exception
(
u'Invalid ssh key: '
)
logger
.
exception
(
u'Invalid ssh key: '
)
Context
.
_save_keys
(
new_keys
)
Context
.
_save_keys
(
new_keys
)
...
@@ -191,7 +191,7 @@ class Context(BaseContext):
...
@@ -191,7 +191,7 @@ class Context(BaseContext):
new_keys
.
remove
(
p
)
new_keys
.
remove
(
p
)
except
ValueError
:
except
ValueError
:
pass
pass
except
:
except
Exception
:
logger
.
exception
(
u'Invalid ssh key: '
)
logger
.
exception
(
u'Invalid ssh key: '
)
Context
.
_save_keys
(
new_keys
)
Context
.
_save_keys
(
new_keys
)
...
...
freebsd/ssh.py
View file @
a108236a
from
base64
import
decodestring
from
base64
import
decodestring
from
struct
import
unpack
from
struct
import
unpack
import
binascii
import
binascii
import
unittest
class
InvalidKeyType
(
Exception
):
class
InvalidKeyType
(
Exception
):
...
@@ -56,8 +57,7 @@ class PubKey(object):
...
@@ -56,8 +57,7 @@ class PubKey(object):
return
u'<PubKey:
%
s>'
%
unicode
(
self
)
return
u'<PubKey:
%
s>'
%
unicode
(
self
)
import
unittest
# Unit tests
class
SshTestCase
(
unittest
.
TestCase
):
class
SshTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -102,5 +102,6 @@ class SshTestCase(unittest.TestCase):
...
@@ -102,5 +102,6 @@ class SshTestCase(unittest.TestCase):
s
.
add
(
self
.
p3
)
s
.
add
(
self
.
p3
)
self
.
assertEqual
(
len
(
s
),
2
)
self
.
assertEqual
(
len
(
s
),
2
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment