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
import
subprocess
import
sys
system
=
platform
.
system
()
working_directory
=
sys
.
path
[
0
]
system
=
platform
.
system
()
# noqa
working_directory
=
sys
.
path
[
0
]
# noqa
try
:
# load virtio console driver, the device is /dev/ttyV0.1
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'virtio_console'
))
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'smbfs'
))
chdir
(
working_directory
)
subprocess
.
call
(
(
'/usr/local/bin/pip'
,
'install'
,
'-r'
,
'requirements.txt'
))
copy
(
"/root/agent/misc/vm_renewal"
,
"/usr/local/bin/"
)
except
:
pass
# hope it works
try
:
# noqa
# load virtio console driver, the device is /dev/ttyV0.1
# noqa
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'virtio_console'
))
# noqa
subprocess
.
call
((
'/sbin/kldload'
,
'-n'
,
'smbfs'
))
# noqa
chdir
(
working_directory
)
# noqa
subprocess
.
call
(
# noqa
(
'/usr/local/bin/pip'
,
'install'
,
'-r'
,
'requirements.txt'
))
# noqa
copy
(
"/root/agent/misc/vm_renewal"
,
"/usr/local/bin/"
)
# noqa
except
Exception
:
# noqa
pass
# hope it works
# noqa
import
logging
...
...
@@ -109,7 +109,7 @@ class Context(BaseContext):
Context
.
_freebsd_set_time
(
float
(
time
))
try
:
subprocess
.
call
([
'/usr/sbin/service'
'ntpd'
,
'onerestart'
])
except
:
except
Exception
:
pass
@staticmethod
...
...
@@ -152,7 +152,7 @@ class Context(BaseContext):
for
line
in
f
.
readlines
():
try
:
retval
.
append
(
PubKey
.
from_str
(
line
))
except
:
except
Exception
:
logger
.
exception
(
u'Invalid ssh key: '
)
except
IOError
:
pass
...
...
@@ -177,7 +177,7 @@ class Context(BaseContext):
p
=
PubKey
.
from_str
(
key
)
if
p
not
in
new_keys
:
new_keys
.
append
(
p
)
except
:
except
Exception
:
logger
.
exception
(
u'Invalid ssh key: '
)
Context
.
_save_keys
(
new_keys
)
...
...
@@ -191,7 +191,7 @@ class Context(BaseContext):
new_keys
.
remove
(
p
)
except
ValueError
:
pass
except
:
except
Exception
:
logger
.
exception
(
u'Invalid ssh key: '
)
Context
.
_save_keys
(
new_keys
)
...
...
freebsd/ssh.py
View file @
a108236a
from
base64
import
decodestring
from
struct
import
unpack
import
binascii
import
unittest
class
InvalidKeyType
(
Exception
):
...
...
@@ -56,8 +57,7 @@ class PubKey(object):
return
u'<PubKey:
%
s>'
%
unicode
(
self
)
import
unittest
# Unit tests
class
SshTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -102,5 +102,6 @@ class SshTestCase(unittest.TestCase):
s
.
add
(
self
.
p3
)
self
.
assertEqual
(
len
(
s
),
2
)
if
__name__
==
'__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