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
8176e5e0
authored
Jun 07, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add update function
parent
56bbc183
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
agent.py
+23
-2
No files found.
agent.py
View file @
8176e5e0
...
...
@@ -10,8 +10,11 @@ import logging
import
subprocess
import
fileinput
import
platform
from
shutil
import
rmtree
# from os import path
import
sys
import
tarfile
from
StringIO
import
StringIO
from
base64
import
decodestring
from
shutil
import
rmtree
,
move
from
datetime
import
datetime
from
utils
import
SerialLineReceiverBase
...
...
@@ -172,6 +175,24 @@ class Context(object):
pass
@staticmethod
def
update
(
data
):
cur_dir
=
sys
.
path
[
0
]
new_dir
=
cur_dir
+
'.new'
old_dir
=
cur_dir
+
'.old'
f
=
StringIO
(
decodestring
(
data
))
try
:
tar
=
tarfile
.
TarFile
.
open
(
"dummy"
,
fileobj
=
f
,
mode
=
'r|bz2'
)
tar
.
extractall
(
new_dir
)
except
tarfile
.
ReadError
as
e
:
logger
.
error
(
e
)
else
:
rmtree
(
old_dir
,
ignore_errors
=
True
)
move
(
cur_dir
,
old_dir
)
move
(
new_dir
,
cur_dir
)
logger
.
info
(
'Updated'
)
reactor
.
stop
()
@staticmethod
def
ipaddresses
():
import
netifaces
args
=
{}
...
...
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