Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
8a4dda6c
Commit
8a4dda6c
authored
Jan 31, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'slapformat'
parents
fe69e4e9
2c9ea680
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
6 deletions
+50
-6
CHANGES.txt
CHANGES.txt
+6
-0
setup.py
setup.py
+3
-1
slapos/entry.py
slapos/entry.py
+3
-2
slapos/format.py
slapos/format.py
+35
-3
slapos/version.py
slapos/version.py
+3
-0
No files found.
CHANGES.txt
View file @
8a4dda6c
Changes
=======
0.34.1 (unreleased)
-------------------
* slapos: display version number with help [Marco Mariani]
* slapformat: backup slapos.xml to a zip archive at every change [Marco Mariani]
0.34 (2013-01-23)
-----------------
...
...
setup.py
View file @
8a4dda6c
from
setuptools
import
setup
,
find_packages
import
glob
import
os
version
=
'0.34.1-dev'
from
slapos.version
import
version
name
=
'slapos.core'
long_description
=
open
(
"README.txt"
).
read
()
+
"
\
n
"
+
\
open
(
"CHANGES.txt"
).
read
()
+
"
\
n
"
...
...
slapos/entry.py
View file @
8a4dda6c
...
...
@@ -43,6 +43,7 @@ from slapos.grid.slapgrid import runUsageReport as report
from
slapos.grid.svcbackend
import
supervisord
from
slapos.grid.svcbackend
import
supervisorctl
from
slapos.register.register
import
main
as
register
from
slapos.version
import
version
# Note: this whole file is a hack. We should better try dedicated library
# like https://github.com/dhellmann/cliff or https://github.com/docopt/docopt.
...
...
@@ -173,7 +174,7 @@ def main():
else
:
is_node
=
False
usage
=
"""SlapOS command line interface.
usage
=
"""SlapOS
%s
command line interface.
For more informations, refer to SlapOS documentation.
Client subcommands usage:
...
...
@@ -195,7 +196,7 @@ Node subcommands usage:
slapos node status <process>
slapos node supervisorctl
slapos node supervisord
"""
"""
%
version
# Parse arguments
# XXX remove the "positional arguments" from help message
...
...
slapos/format.py
View file @
8a4dda6c
# -*- coding: utf-8 -*-
# vim: set et sts=2:
##############################################################################
#
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
...
...
@@ -46,6 +47,15 @@ import subprocess
import
sys
import
threading
import
time
import
zipfile
import
lxml.etree
def
prettify_xml
(
xml
):
root
=
lxml
.
etree
.
fromstring
(
xml
)
return
lxml
.
etree
.
tostring
(
root
,
pretty_print
=
True
)
class
OS
(
object
):
_os
=
os
...
...
@@ -253,9 +263,31 @@ class Computer(object):
"""
computer_dict
=
_getDict
(
self
)
output_file
=
open
(
path_to_xml
,
'w'
)
output_file
.
write
(
xml_marshaller
.
dumps
(
computer_dict
))
output_file
.
close
()
new_xml
=
xml_marshaller
.
dumps
(
computer_dict
)
new_pretty_xml
=
prettify_xml
(
new_xml
)
path_to_archive
=
path_to_xml
+
'.zip'
if
os
.
path
.
exists
(
path_to_archive
):
# the archive file exists, we only backup if something has changed
with
open
(
path_to_xml
,
'rb'
)
as
fin
:
if
fin
.
read
()
==
new_pretty_xml
:
# computer configuration did not change, nothing to write
return
self
.
backup_xml
(
path_to_archive
,
path_to_xml
)
with
open
(
path_to_xml
,
'wb'
)
as
fout
:
fout
.
write
(
new_pretty_xml
)
def
backup_xml
(
self
,
path_to_archive
,
path_to_xml
):
xml_content
=
open
(
path_to_xml
).
read
()
saved_filename
=
path_to_xml
+
time
.
strftime
(
'.%Y%M%d-%H:%M'
)
with
zipfile
.
ZipFile
(
path_to_archive
,
'a'
)
as
archive
:
archive
.
writestr
(
saved_filename
,
xml_content
,
zipfile
.
ZIP_DEFLATED
)
@
classmethod
def
load
(
cls
,
path_to_xml
,
reference
,
ipv6_interface
):
...
...
slapos/version.py
0 → 100644
View file @
8a4dda6c
version
=
'0.34.1-dev'
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