Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.toolbox
Commits
317b1abf
Commit
317b1abf
authored
Jun 21, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix utf-8 encoding problèm
parent
28be25ee
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
16 deletions
+51
-16
slapos/runner/gittools.py
slapos/runner/gittools.py
+3
-1
slapos/runner/static/css/jqueryTabs.css
slapos/runner/static/css/jqueryTabs.css
+2
-5
slapos/runner/static/js/scripts/inspectInstance.js
slapos/runner/static/js/scripts/inspectInstance.js
+22
-0
slapos/runner/templates/instanceInspect.html
slapos/runner/templates/instanceInspect.html
+4
-3
slapos/runner/utils.py
slapos/runner/utils.py
+6
-3
slapos/runner/views.py
slapos/runner/views.py
+14
-4
No files found.
slapos/runner/gittools.py
View file @
317b1abf
# -*- coding: utf-8 -*-
import
slapos.slap
import
slapos.slap
import
time
import
time
import
subprocess
import
subprocess
...
@@ -34,7 +36,7 @@ def cloneRepo(data):
...
@@ -34,7 +36,7 @@ def cloneRepo(data):
config_writer
=
repo
.
config_writer
()
config_writer
=
repo
.
config_writer
()
config_writer
.
add_section
(
"user"
)
config_writer
.
add_section
(
"user"
)
if
data
[
"user"
]
!=
""
:
if
data
[
"user"
]
!=
""
:
config_writer
.
set_value
(
"user"
,
"name"
,
data
[
"user"
])
config_writer
.
set_value
(
"user"
,
"name"
,
data
[
"user"
]
.
encode
(
"utf-8"
)
)
if
data
[
"email"
]
!=
""
:
if
data
[
"email"
]
!=
""
:
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
code
=
1
code
=
1
...
...
slapos/runner/static/css/jqueryTabs.css
View file @
317b1abf
...
@@ -9,12 +9,9 @@
...
@@ -9,12 +9,9 @@
#tabContaier
textarea
{
#tabContaier
textarea
{
width
:
702px
;
width
:
702px
;
resize
:
none
;
white-space
:
pre-wrap
;
word-wrap
:
break-word
;
}
}
#tabContaier
textarea
.slap
{
white-space
:
pre-wrap
;
word-wrap
:
break-word
;
overflow
:
hidden
;
color
:
#6F6F6F
;
width
:
430px
;
max-height
:
120px
;
#tabContaier
textarea
.slap
{
color
:
#6F6F6F
;
width
:
430px
;
max-height
:
120px
;
height
:
18px
;
padding
:
3
px
;}
resize
:
none
;
height
:
18px
;
padding
:
3px
;
min-height
:
18
px
;}
#tabContaier
>
ul
{
#tabContaier
>
ul
{
overflow
:
hidden
;
overflow
:
hidden
;
height
:
34px
;
height
:
34px
;
...
...
slapos/runner/static/js/scripts/inspectInstance.js
View file @
317b1abf
...
@@ -44,6 +44,7 @@ $(document).ready( function() {
...
@@ -44,6 +44,7 @@ $(document).ready( function() {
"
</td><td valign='middle'><span style='margin-left: 10px;' id='btn_
"
+
size
+
"
' class='close'></span></td></tr>
"
;
"
</td><td valign='middle'><span style='margin-left: 10px;' id='btn_
"
+
size
+
"
' class='close'></span></td></tr>
"
;
$
(
"
#partitionParameter
"
).
append
(
row
);
$
(
"
#partitionParameter
"
).
append
(
row
);
setInput
(
$
(
"
input#txt_
"
+
size
));
setInput
(
$
(
"
input#txt_
"
+
size
));
setupTextarea
(
$
(
"
textarea#value_
"
+
size
));
$
(
"
#btn_
"
+
size
).
click
(
function
(){
$
(
"
#btn_
"
+
size
).
click
(
function
(){
var
index
=
$
(
this
).
attr
(
'
id
'
).
split
(
'
_
'
)[
1
];
var
index
=
$
(
this
).
attr
(
'
id
'
).
split
(
'
_
'
)[
1
];
$
(
"
tr#row_
"
+
index
).
remove
();
$
(
"
tr#row_
"
+
index
).
remove
();
...
@@ -101,6 +102,12 @@ $(document).ready( function() {
...
@@ -101,6 +102,12 @@ $(document).ready( function() {
});
});
//Load previous instance parameters
//Load previous instance parameters
loadParameter
();
loadParameter
();
$
(
"
a#parameterTab
"
).
click
(
function
(){
var
size
=
$
(
"
#partitionParameter > tbody > tr
"
).
length
;
for
(
var
i
=
2
;
i
<=
size
;
i
++
){
$
(
"
textarea#value_
"
+
i
).
keyup
();
}
});
function
setupFileTree
(
path
){
function
setupFileTree
(
path
){
var
root
=
$
(
"
input#root
"
).
val
();
var
root
=
$
(
"
input#root
"
).
val
();
...
@@ -214,6 +221,20 @@ $(document).ready( function() {
...
@@ -214,6 +221,20 @@ $(document).ready( function() {
}
}
});
});
}
}
function
setupTextarea
(
$txt
){
var
size
=
Number
(
$txt
.
attr
(
'
id
'
).
split
(
'
_
'
)[
1
]);
var
hiddenDiv
=
$
(
document
.
createElement
(
'
div
'
)),
content
=
null
;
hiddenDiv
.
attr
(
'
id
'
,
'
div_
'
+
size
);
hiddenDiv
.
addClass
(
'
hiddendiv
'
);
$
(
'
div#parameterkw
'
).
append
(
hiddenDiv
);
$txt
.
keyup
(
function
()
{
content
=
$txt
.
val
().
replace
(
/
\n
/g
,
'
<br>
'
);
hiddenDiv
.
html
(
content
);
if
(
hiddenDiv
.
height
()
>
$txt
.
height
()
&&
hiddenDiv
.
height
()
>
120
){
return
}
$txt
.
css
(
'
height
'
,
hiddenDiv
.
height
()
+
"
px
"
);
});
}
function
loadParameter
(){
function
loadParameter
(){
$
.
ajax
({
$
.
ajax
({
type
:
"
GET
"
,
type
:
"
GET
"
,
...
@@ -226,6 +247,7 @@ $(document).ready( function() {
...
@@ -226,6 +247,7 @@ $(document).ready( function() {
var
size
=
Number
(
$
(
"
#partitionParameter > tbody > tr
"
).
last
().
attr
(
'
id
'
).
split
(
'
_
'
)[
1
]);
var
size
=
Number
(
$
(
"
#partitionParameter > tbody > tr
"
).
last
().
attr
(
'
id
'
).
split
(
'
_
'
)[
1
]);
$
(
"
input#txt_
"
+
size
).
val
(
propertie
);
$
(
"
input#txt_
"
+
size
).
val
(
propertie
);
$
(
"
textarea#value_
"
+
size
).
val
(
dict
[
propertie
]);
$
(
"
textarea#value_
"
+
size
).
val
(
dict
[
propertie
]);
$
(
"
textarea#value_
"
+
size
).
keyup
();
}
}
}
}
else
{
else
{
...
...
slapos/runner/templates/instanceInspect.html
View file @
317b1abf
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<ul>
<ul>
<li><a
href=
"#tab1"
class=
"active"
>
Slapgrid Supervisor
</a></li>
<li><a
href=
"#tab1"
class=
"active"
>
Slapgrid Supervisor
</a></li>
<li><a
href=
"#tab2"
>
SLAP Response
</a></li>
<li><a
href=
"#tab2"
>
SLAP Response
</a></li>
<li><a
href=
"#tab3"
>
Parameters
</a></li>
<li><a
href=
"#tab3"
id=
"parameterTab"
>
Parameters
</a></li>
<li><a
href=
"#tab4"
id=
"instancetabfiles"
>
Partitions Content
</a></li>
<li><a
href=
"#tab4"
id=
"instancetabfiles"
>
Partitions Content
</a></li>
</ul>
<!-- //Tab buttons -->
</ul>
<!-- //Tab buttons -->
<div
class=
"tabDetails"
>
<div
class=
"tabDetails"
>
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
<div
id=
"box{{item[0]}}"
style=
"display:none;"
>
<div
id=
"box{{item[0]}}"
style=
"display:none;"
>
{% if item[1] %}
{% if item[1] %}
<h2><span
style=
"float:left; margin-left:10px;"
id=
"{{item[0]}}title"
>
Slap Response for {{item[0]}}
</span>
<h2><span
style=
"float:left; margin-left:10px;"
id=
"{{item[0]}}title"
>
Slap Response for {{item[0]}}
</span>
<a
href=
"#"
id=
"{{item[0]}}Parameter"
rel=
"{{item[0]}}"
class=
"lshare simple"
style=
"float:right"
>
Parameters
</a>
<a
href=
"#"
id=
"{{item[0]}}Parameter"
rel=
"{{item[0]}}"
class=
"lshare simple"
style=
"float:right"
title=
'Restart all partition process'
>
Restart
</a>
<a
href=
"#"
id=
"{{item[0]}}Files"
rel=
"{{item[0]}}"
class=
"lshare simple no-right-border"
style=
"float:right"
>
Files
</a>
<a
href=
"#"
id=
"{{item[0]}}Files"
rel=
"{{item[0]}}"
class=
"lshare simple no-right-border"
style=
"float:right"
>
Files
</a>
</h2>
</h2>
<div
class=
"clear"
></div><br/>
<div
class=
"clear"
></div><br/>
...
@@ -124,7 +124,7 @@
...
@@ -124,7 +124,7 @@
</div>
<!-- end tab3 -->
</div>
<!-- end tab3 -->
<div
id=
"tab4"
class=
"tabContents"
>
<div
id=
"tab4"
class=
"tabContents"
>
<h2>
File content for all your partitions
</h2>
<h2>
File content for all your partitions
</h2>
<div
id=
"fileTree"
class=
"file_tree_tabs"
alt
=
"Double click to open file"
></div>
<div
id=
"fileTree"
class=
"file_tree_tabs"
title
=
"Double click to open file"
></div>
<br/>
<br/>
<a
href=
"#"
id=
"reloadfiles"
class=
"lshare simple"
>
Reload Files
</a>
<a
href=
"#"
id=
"reloadfiles"
class=
"lshare simple"
>
Reload Files
</a>
</div>
<!-- end tab4 -->
</div>
<!-- end tab4 -->
...
@@ -137,4 +137,5 @@
...
@@ -137,4 +137,5 @@
</div>
</div>
</div>
</div>
{{instance}}
{% endblock %}
{% endblock %}
slapos/runner/utils.py
View file @
317b1abf
# -*- coding:
iso-8859-1
-*-
# -*- coding:
utf-8
-*-
import
slapos.slap
import
slapos.slap
import
time
import
time
...
@@ -95,6 +95,8 @@ def updateProxy(config):
...
@@ -95,6 +95,8 @@ def updateProxy(config):
xml_result
=
readParameters
(
param_path
)
xml_result
=
readParameters
(
param_path
)
partition_parameter_kw
=
None
partition_parameter_kw
=
None
if
type
(
xml_result
)
!=
type
(
''
)
and
xml_result
.
has_key
(
'instance'
):
if
type
(
xml_result
)
!=
type
(
''
)
and
xml_result
.
has_key
(
'instance'
):
for
item
in
xml_result
[
'instance'
].
keys
():
xml_result
[
'instance'
][
item
]
=
xml_result
[
'instance'
][
item
].
decode
(
'utf-8'
)
partition_parameter_kw
=
xml_result
[
'instance'
]
partition_parameter_kw
=
xml_result
[
'instance'
]
computer
.
updateConfiguration
(
xml_marshaller
.
dumps
(
slap_config
))
computer
.
updateConfiguration
(
xml_marshaller
.
dumps
(
slap_config
))
sr_request
=
slap
.
registerOpenOrder
().
request
(
profile
,
partition_reference
=
getSoftwareReleaseName
(
config
),
sr_request
=
slap
.
registerOpenOrder
().
request
(
profile
,
partition_reference
=
getSoftwareReleaseName
(
config
),
...
@@ -133,6 +135,8 @@ def updateInstanceParameter(config, software_type=None):
...
@@ -133,6 +135,8 @@ def updateInstanceParameter(config, software_type=None):
xml_result
=
readParameters
(
param_path
)
xml_result
=
readParameters
(
param_path
)
partition_parameter_kw
=
None
partition_parameter_kw
=
None
if
type
(
xml_result
)
!=
type
(
''
)
and
xml_result
.
has_key
(
'instance'
):
if
type
(
xml_result
)
!=
type
(
''
)
and
xml_result
.
has_key
(
'instance'
):
#for item in xml_result['instance'].keys():
# xml_result['instance'][item] = xml_result['instance'][item].decode('utf-8')
partition_parameter_kw
=
xml_result
[
'instance'
]
partition_parameter_kw
=
xml_result
[
'instance'
]
slap
.
registerOpenOrder
().
request
(
profile
,
partition_reference
=
getSoftwareReleaseName
(
config
),
slap
.
registerOpenOrder
().
request
(
profile
,
partition_reference
=
getSoftwareReleaseName
(
config
),
partition_parameter_kw
=
partition_parameter_kw
,
software_type
=
software_type
,
partition_parameter_kw
=
partition_parameter_kw
,
software_type
=
software_type
,
...
@@ -634,8 +638,7 @@ def readParameters(path):
...
@@ -634,8 +638,7 @@ def readParameters(path):
sub_object = {}
sub_object = {}
for subnode in elt.childNodes:
for subnode in elt.childNodes:
if subnode.nodeType != subnode.TEXT_NODE:
if subnode.nodeType != subnode.TEXT_NODE:
sub_object[str(subnode.getAttribute('
id
'))] = str(subnode.
sub_object[str(subnode.getAttribute('
id
'))] = subnode.childNodes[0].data #.decode('
utf
-
8
').decode('
utf
-
8
')
childNodes[0].data)
object[str(elt.tagName)] = sub_object
object[str(elt.tagName)] = sub_object
return object
return object
except Exception, e:
except Exception, e:
...
...
slapos/runner/views.py
View file @
317b1abf
...
@@ -6,7 +6,6 @@ from utils import *
...
@@ -6,7 +6,6 @@ from utils import *
import
os
import
os
import
shutil
import
shutil
import
md5
import
md5
import
codecs
from
gittools
import
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
\
from
gittools
import
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
\
gitPush
,
gitPull
gitPush
,
gitPull
...
@@ -14,7 +13,8 @@ app = Flask(__name__)
...
@@ -14,7 +13,8 @@ app = Flask(__name__)
@
app
.
before_request
@
app
.
before_request
def
before_request
():
def
before_request
():
if
not
session
.
has_key
(
'account'
)
and
request
.
path
!=
'/login'
\
if
(
not
session
.
has_key
(
'account'
)
or
not
session
[
'account'
])
\
and
request
.
path
!=
'/login'
\
and
request
.
path
!=
'/doLogin'
and
not
request
.
path
.
startswith
(
'/static'
):
and
request
.
path
!=
'/doLogin'
and
not
request
.
path
.
startswith
(
'/static'
):
return
redirect
(
url_for
(
'login'
))
return
redirect
(
url_for
(
'login'
))
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
...
@@ -30,6 +30,16 @@ def home():
...
@@ -30,6 +30,16 @@ def home():
def
login
():
def
login
():
return
render_template
(
'login.html'
)
return
render_template
(
'login.html'
)
@
app
.
route
(
"/myAccount"
)
def
myAccount
():
return
render_template
(
'account.html'
,
username
=
session
[
'account'
][
0
],
email
=
session
[
'account'
][
2
],
name
=
session
[
'account'
][
3
])
@
app
.
route
(
"/logout"
)
def
logout
():
session
[
'account'
]
=
None
return
redirect
(
url_for
(
'login'
))
@
app
.
route
(
'/configRepo'
)
@
app
.
route
(
'/configRepo'
)
def
configRepo
():
def
configRepo
():
public_key
=
open
(
app
.
config
[
'public_key'
],
'r'
).
read
()
public_key
=
open
(
app
.
config
[
'public_key'
],
'r'
).
read
()
...
@@ -290,7 +300,7 @@ def getFileContent():
...
@@ -290,7 +300,7 @@ def getFileContent():
def
saveFileContent
():
def
saveFileContent
():
file_path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
file_path
=
realpath
(
app
.
config
,
request
.
form
[
'file'
])
if
file_path
:
if
file_path
:
open
(
file_path
,
'w'
).
write
(
request
.
form
[
'content'
])
open
(
file_path
,
'w'
).
write
(
request
.
form
[
'content'
]
.
encode
(
"utf-8"
)
)
return
jsonify
(
code
=
1
,
result
=
""
)
return
jsonify
(
code
=
1
,
result
=
""
)
else
:
else
:
return
jsonify
(
code
=
0
,
result
=
"Error: No such file!"
)
return
jsonify
(
code
=
0
,
result
=
"Error: No such file!"
)
...
@@ -398,7 +408,7 @@ def saveParameterXml():
...
@@ -398,7 +408,7 @@ def saveParameterXml():
project
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".project"
)
project
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".project"
)
if
not
os
.
path
.
exists
(
project
):
if
not
os
.
path
.
exists
(
project
):
return
jsonify
(
code
=
0
,
result
=
"Please first open a Software Release"
)
return
jsonify
(
code
=
0
,
result
=
"Please first open a Software Release"
)
content
=
request
.
form
[
'parameter'
]
content
=
request
.
form
[
'parameter'
]
.
encode
(
"utf-8"
)
param_path
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".parameter.xml"
)
param_path
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".parameter.xml"
)
try
:
try
:
f
=
open
(
param_path
,
'w'
)
f
=
open
(
param_path
,
'w'
)
...
...
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