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
555e93a1
authored
Sep 15, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update method rework
parent
3521bf56
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
agent.py
+38
-2
No files found.
agent.py
View file @
555e93a1
...
...
@@ -264,8 +264,8 @@ class Context(object):
# TODO
pass
@
static
method
def
update
(
data
,
uuid
):
@
class
method
def
_update_linux
(
cls
,
data
,
uuid
):
cur_dir
=
sys
.
path
[
0
]
new_dir
=
cur_dir
+
'.new'
old_dir
=
cur_dir
+
'.old'
...
...
@@ -282,6 +282,42 @@ class Context(object):
logger
.
info
(
'Updated'
)
reactor
.
stop
()
@classmethod
def
_update_windows
(
cls
,
data
,
executable
,
uuid
):
# Extract the tar to the new path
cur_dir
=
sys
.
path
[
0
]
new_dir
=
cur_dir
+
'.version'
f
=
StringIO
(
decodestring
(
data
))
try
:
tar
=
tarfile
.
TarFile
.
open
(
"dummy"
,
fileobj
=
f
,
mode
=
'r|gz'
)
tar
.
extractall
(
new_dir
)
except
tarfile
.
ReadError
as
e
:
logger
.
error
(
e
)
else
:
cls
.
_update_registry
(
new_dir
,
executable
)
logger
.
info
(
'Updated'
)
reactor
.
stop
()
@classmethod
def
_update_registry
(
cls
,
dir
,
executable
):
# HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\circle-agent
from
_winreg
import
(
OpenKeyEx
,
SetValueEx
,
QueryValueEx
,
HKEY_LOCAL_MACHINE
,
KEY_ALL_ACCESS
)
with
OpenKeyEx
(
HKEY_LOCAL_MACHINE
,
r'SYSTEM\CurrentControlSet\services\circle-agent'
,
0
,
KEY_ALL_ACCESS
)
as
key
:
(
old_executable
,
reg_type
)
=
QueryValueEx
(
key
,
"ImagePath"
)
SetValueEx
(
key
,
"ImagePath"
,
None
,
2
,
join
(
dir
,
executable
))
return
old_executable
@staticmethod
def
update
(
data
,
executable
,
uuid
):
if
system
==
"Windows"
:
Context
.
_update_windows
(
data
,
executable
,
uuid
)
else
:
Context
.
_update_linux
(
data
,
executable
,
uuid
)
@staticmethod
def
ipaddresses
():
import
netifaces
...
...
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