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
26858401
authored
Nov 07, 2018
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-flake8-warnings' into 'master'
Fix flake8 warnings See merge request
!7
parents
d2fa1c61
09457c96
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
25 deletions
+36
-25
agent-winservice.py
+2
-1
agent.py
+12
-10
linux/_linuxcontext.py
+8
-5
linux/ssh.py
+3
-2
notify.py
+6
-3
watchdog-winservice.py
+2
-1
windows/_win32context.py
+1
-1
windows/network.py
+1
-1
windows/win32virtio.py
+1
-1
No files found.
agent-winservice.py
View file @
26858401
...
...
@@ -61,10 +61,11 @@ def main():
else
:
win32serviceutil
.
HandleCommandLine
(
AppServerSvc
)
if
__name__
==
'__main__'
:
try
:
main
()
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
:
except
Exception
:
logger
.
exception
(
"Exception:"
)
agent.py
View file @
26858401
...
...
@@ -6,14 +6,15 @@ import platform
import
subprocess
import
sys
system
=
platform
.
system
()
if
system
==
"Linux"
or
system
==
"FreeBSD"
:
try
:
chdir
(
sys
.
path
[
0
])
subprocess
.
call
((
'pip'
,
'install'
,
'-r'
,
'requirements.txt'
))
except
:
pass
# hope it works
system
=
platform
.
system
()
# noqa
if
system
==
"Linux"
or
system
==
"FreeBSD"
:
# noqa
try
:
# noqa
chdir
(
sys
.
path
[
0
])
# noqa
subprocess
.
call
((
'pip'
,
'install'
,
'-r'
,
'requirements.txt'
))
# noqa
except
Exception
:
# noqa
pass
# hope it works # noqa
from
twisted.internet
import
reactor
,
defer
...
...
@@ -35,6 +36,7 @@ Context = get_context()
logging
.
basicConfig
()
logger
=
logging
.
getLogger
()
level
=
environ
.
get
(
'LOGLEVEL'
,
'INFO'
)
logger
.
setLevel
(
level
)
...
...
@@ -65,7 +67,7 @@ class SerialLineReceiver(SerialLineReceiverBase):
logger
.
debug
(
"Sending tick"
)
try
:
self
.
send_status
()
except
:
except
Exception
:
logger
.
exception
(
"Twisted hide exception"
)
def
__init__
(
self
):
...
...
@@ -136,7 +138,7 @@ class SerialLineReceiver(SerialLineReceiverBase):
if
argspec
.
keywords
:
args
.
append
(
"**"
+
argspec
.
keywords
)
return
"
%
s(
%
s)"
%
(
fun
.
__name__
,
","
.
join
(
args
))
except
:
except
Exception
:
return
"<
%
s>"
%
type
(
fun
)
.
__name__
def
handle_command
(
self
,
command
,
args
):
...
...
@@ -159,7 +161,7 @@ def main():
try
:
from
notify
import
register_publisher
register_publisher
(
reactor
)
except
:
except
Exception
:
logger
.
exception
(
"Could not register notify publisher"
)
logger
.
debug
(
"Starting reactor."
)
reactor
.
run
()
...
...
linux/_linuxcontext.py
View file @
26858401
...
...
@@ -8,7 +8,9 @@ from shutil import rmtree, move
import
subprocess
import
sys
working_directory
=
sys
.
path
[
0
]
working_directory
=
sys
.
path
[
0
]
# noqa
import
logging
import
fileinput
...
...
@@ -26,6 +28,7 @@ from context import BaseContext
from
twisted.internet
import
reactor
logger
=
logging
.
getLogger
()
SSH_DIR
=
expanduser
(
'~cloud/.ssh'
)
...
...
@@ -96,7 +99,7 @@ class Context(BaseContext):
Context
.
_linux_set_time
(
float
(
time
))
try
:
subprocess
.
call
([
'/etc/init.d/ntp'
,
'restart'
])
except
:
except
Exception
:
pass
@staticmethod
...
...
@@ -142,7 +145,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
...
...
@@ -170,7 +173,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
)
...
...
@@ -184,7 +187,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
)
...
...
linux/ssh.py
View file @
26858401
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
()
notify.py
View file @
26858401
...
...
@@ -120,7 +120,7 @@ def notify(url):
logger
.
debug
(
"wall sent, trying to start browser"
)
p
=
multiprocessing
.
Process
(
target
=
open_in_browser
,
args
=
(
url
,
))
p
.
start
()
except
:
except
Exception
:
logger
.
exception
(
"Couldn't notify about
%
s"
%
url
)
...
...
@@ -152,7 +152,7 @@ def mount_smb(url):
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
)
logger
.
info
(
'mount_smb():
%
s'
,
p
.
communicate
())
except
:
except
Exception
:
logger
.
exception
(
'Unhandled exception: '
)
...
...
@@ -191,10 +191,11 @@ def search_display():
if
"DISPLAY"
in
envs
and
":"
in
envs
[
"DISPLAY"
]:
p
=
os
.
stat
(
os
.
path
.
join
(
"/proc"
,
pid
))
return
envs
[
"DISPLAY"
],
p
.
st_uid
,
p
.
st_gid
except
:
except
Exception
:
continue
return
None
if
win
:
from
twisted.internet
import
protocol
from
twisted.protocols
import
basic
...
...
@@ -256,5 +257,7 @@ def main():
args
=
parse_arguments
()
notify
(
args
.
url
)
if
__name__
==
'__main__'
:
main
()
watchdog-winservice.py
View file @
26858401
...
...
@@ -80,10 +80,11 @@ def main():
else
:
win32serviceutil
.
HandleCommandLine
(
AppServerSvc
)
if
__name__
==
'__main__'
:
try
:
main
()
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
:
except
Exception
:
logger
.
exception
(
"Exception:"
)
windows/_win32context.py
View file @
26858401
#!/usr/bin/env python
# -*- coding: utf-8 -*-
working_directory
=
r"C:\circle"
working_directory
=
r"C:\circle"
# noqa
from
os.path
import
join
...
...
windows/network.py
View file @
26858401
...
...
@@ -29,7 +29,7 @@ def check_output2(cmd, shell=False):
stdout
,
stderr
=
p
.
communicate
()
logger
.
info
(
'
%
s:
%
s,
%
s'
,
cmd
,
stdout
,
stderr
)
return
stdout
except
:
except
Exception
:
logger
.
exception
(
'Unhandled exception in
%
s: '
,
cmd
)
...
...
windows/win32virtio.py
View file @
26858401
...
...
@@ -78,7 +78,7 @@ class SerialPort(abstract.FileDescriptor):
self
.
hComPort
,
self
.
_overlappedRead
,
0
)
except
:
except
Exception
:
import
time
time
.
sleep
(
10
)
n
=
0
...
...
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