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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
slapos.toolbox
Commits
c3ad77a6
Commit
c3ad77a6
authored
Oct 12, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pylint-ified
parent
29e73bc9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
66 deletions
+78
-66
slapos/runner/decorators.py
slapos/runner/decorators.py
+1
-0
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+1
-1
slapos/runner/gittools.py
slapos/runner/gittools.py
+3
-1
slapos/runner/runnertest.py
slapos/runner/runnertest.py
+25
-19
slapos/runner/utils.py
slapos/runner/utils.py
+35
-35
slapos/runner/views.py
slapos/runner/views.py
+13
-10
No files found.
slapos/runner/decorators.py
View file @
c3ad77a6
# -*- coding: utf-8 -*-
# vim: set et sts=2:
#pylint: disable-all
import
json
...
...
slapos/runner/fileBrowser.py
View file @
c3ad77a6
...
...
@@ -14,7 +14,7 @@ import werkzeug
from
slapos.runner.utils
import
realpath
,
tail
,
isText
class
f
ileBrowser
(
object
):
class
F
ileBrowser
(
object
):
"""This class contain all bases function for file browser"""
def
__init__
(
self
,
config
):
...
...
slapos/runner/gittools.py
View file @
c3ad77a6
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# pylint: disable-msg=W0311,C0301,C0103,C0111
import
os
import
re
...
...
@@ -163,5 +165,5 @@ def gitPull(project):
def
safeResult
(
result
):
"""Parse string and remove credential of the user"""
regex
=
re
.
compile
(
"(https:
\
/
\
/)([
\
w
\
d
\
._-]+:[
\
w
\
d
\
._-]+)
\
@([
\
S]+
\
s)
"
, re.VERBOSE)
regex
=
re
.
compile
(
"(https:
\
/
\
/)([
\
w
\
d
\
._-]+:[
\
w
\
d
\
._-]+)
\
@([
\
S]+
\
s)
"
, re.VERBOSE)
return regex.sub(r'
\
1
\
3
', result)
slapos/runner/runnertest.py
View file @
c3ad77a6
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# pylint: disable-msg=W0311,C0301,C0103,C0111,R0904
import
ConfigParser
import
datetime
...
...
@@ -12,8 +13,18 @@ from slapos.runner.utils import (getProfilePath, getSession, isInstanceRunning,
recursifKill
,
startProxy
)
from
slapos.runner
import
views
#Helpers
def
loadJson
(
response
):
return
json
.
loads
(
response
.
data
)
class
Config
:
def
__init__
(
self
):
self
.
runner_workdir
=
None
self
.
software_root
=
None
self
.
instance_root
=
None
self
.
configuration_file_path
=
None
def
setConfig
(
self
):
"""
Set options given by parameters.
...
...
@@ -97,11 +108,6 @@ class SlaprunnerTestCase(unittest.TestCase):
if
os
.
path
.
exists
(
self
.
app
.
config
[
'instance_root'
]):
shutil
.
rmtree
(
self
.
app
.
config
[
'instance_root'
])
#Helpers
def
loadJson
(
self
,
response
):
return
json
.
loads
(
response
.
data
)
def
configAccount
(
self
,
username
,
password
,
email
,
name
,
rcode
):
"""Helper for configAccount"""
return
self
.
app
.
post
(
'/configAccount'
,
data
=
dict
(
...
...
@@ -121,9 +127,9 @@ class SlaprunnerTestCase(unittest.TestCase):
def
setAccount
(
self
):
"""Initialize user account and log user in"""
response
=
self
.
loadJson
(
self
.
configAccount
(
self
.
users
[
0
],
self
.
users
[
1
],
response
=
loadJson
(
self
.
configAccount
(
self
.
users
[
0
],
self
.
users
[
1
],
self
.
users
[
2
],
self
.
users
[
3
],
self
.
rcode
))
response2
=
self
.
loadJson
(
self
.
login
(
self
.
users
[
0
],
self
.
users
[
1
]))
response2
=
loadJson
(
self
.
login
(
self
.
users
[
0
],
self
.
users
[
1
]))
self
.
assertEqual
(
response
[
'result'
],
""
)
self
.
assertEqual
(
response2
[
'result'
],
""
)
...
...
@@ -172,22 +178,22 @@ class SlaprunnerTestCase(unittest.TestCase):
"""For the first lauch of slaprunner user need do create first account"""
result
=
self
.
configAccount
(
self
.
users
[
0
],
self
.
users
[
1
],
self
.
users
[
2
],
self
.
users
[
3
],
self
.
rcode
)
response
=
self
.
loadJson
(
result
)
response
=
loadJson
(
result
)
self
.
assertEqual
(
response
[
'code'
],
1
)
account
=
getSession
(
self
.
app
.
config
)
self
.
assertEqual
(
account
,
self
.
users
)
def
test_login_logout
(
self
):
"""test login with good and wrong values, test logout"""
response
=
self
.
loadJson
(
self
.
configAccount
(
self
.
users
[
0
],
self
.
users
[
1
],
response
=
loadJson
(
self
.
configAccount
(
self
.
users
[
0
],
self
.
users
[
1
],
self
.
users
[
2
],
self
.
users
[
3
],
self
.
rcode
))
self
.
assertEqual
(
response
[
'result'
],
""
)
result
=
self
.
loadJson
(
self
.
login
(
self
.
users
[
0
],
"wrongpwd"
))
result
=
loadJson
(
self
.
login
(
self
.
users
[
0
],
"wrongpwd"
))
self
.
assertEqual
(
result
[
'result'
],
"Login or password is incorrect, please check it!"
)
resultwr
=
self
.
loadJson
(
self
.
login
(
"wronglogin"
,
"wrongpwd"
))
resultwr
=
loadJson
(
self
.
login
(
"wronglogin"
,
"wrongpwd"
))
self
.
assertEqual
(
resultwr
[
'result'
],
"Login or password is incorrect, please check it!"
)
#try now with true values
resultlg
=
self
.
loadJson
(
self
.
login
(
self
.
users
[
0
],
self
.
users
[
1
]))
resultlg
=
loadJson
(
self
.
login
(
self
.
users
[
0
],
self
.
users
[
1
]))
self
.
assertEqual
(
resultlg
[
'result'
],
""
)
#after login test logout
result
=
self
.
logout
()
...
...
@@ -196,12 +202,12 @@ class SlaprunnerTestCase(unittest.TestCase):
def
test_updateAccount
(
self
):
"""test Update accound, this need user to loging in"""
self
.
setAccount
()
response
=
self
.
loadJson
(
self
.
updateAccount
(
self
.
updateUser
,
self
.
rcode
))
response
=
loadJson
(
self
.
updateAccount
(
self
.
updateUser
,
self
.
rcode
))
self
.
assertEqual
(
response
[
'code'
],
1
)
result
=
self
.
logout
()
assert
"<h2>Login to Slapos Web Runner</h2>"
in
result
.
data
#retry login with new values
response
=
self
.
loadJson
(
self
.
login
(
self
.
updateUser
[
0
],
self
.
updateUser
[
1
]))
response
=
loadJson
(
self
.
login
(
self
.
updateUser
[
0
],
self
.
updateUser
[
1
]))
self
.
assertEqual
(
response
[
'result'
],
""
)
#log out now!
self
.
logout
()
...
...
@@ -218,12 +224,12 @@ class SlaprunnerTestCase(unittest.TestCase):
folder
=
'workspace/'
+
self
.
project
data
=
{
"repo"
:
self
.
repo
,
"user"
:
'Slaprunner test'
,
"email"
:
'slaprunner@nexedi.com'
,
"name"
:
folder
}
response
=
self
.
loadJson
(
self
.
app
.
post
(
'/cloneRepository'
,
data
=
data
,
response
=
loadJson
(
self
.
app
.
post
(
'/cloneRepository'
,
data
=
data
,
follow_redirects
=
True
))
self
.
assertEqual
(
response
[
'result'
],
""
)
#Get realpath of create project
path_data
=
dict
(
file
=
folder
)
response
=
self
.
loadJson
(
self
.
app
.
post
(
'/getPath'
,
data
=
path_data
,
response
=
loadJson
(
self
.
app
.
post
(
'/getPath'
,
data
=
path_data
,
follow_redirects
=
True
))
self
.
assertEqual
(
response
[
'code'
],
1
)
realFolder
=
response
[
'result'
].
split
(
'#'
)[
0
]
...
...
@@ -231,7 +237,7 @@ class SlaprunnerTestCase(unittest.TestCase):
config
=
open
(
os
.
path
.
join
(
realFolder
,
'.git/config'
),
'r'
).
read
()
assert
"slaprunner@nexedi.com"
in
config
and
"Slaprunner test"
in
config
#Checkout to slaprunner branch, this supose that branch slaprunner exit
response
=
self
.
loadJson
(
self
.
app
.
post
(
'/newBranch'
,
data
=
dict
(
response
=
loadJson
(
self
.
app
.
post
(
'/newBranch'
,
data
=
dict
(
project
=
folder
,
create
=
'0'
,
name
=
'slaprunner'
),
...
...
@@ -246,7 +252,7 @@ class SlaprunnerTestCase(unittest.TestCase):
self
.
login
(
self
.
users
[
0
],
self
.
users
[
1
])
#test create SR
newSoftware
=
os
.
path
.
join
(
self
.
software
,
'slaprunner-test'
)
response
=
self
.
loadJson
(
self
.
app
.
post
(
'/createSoftware'
,
response
=
loadJson
(
self
.
app
.
post
(
'/createSoftware'
,
data
=
dict
(
folder
=
newSoftware
),
follow_redirects
=
True
))
self
.
assertEqual
(
response
[
'result'
],
""
)
...
...
@@ -260,7 +266,7 @@ class SlaprunnerTestCase(unittest.TestCase):
#Login
self
.
login
(
self
.
users
[
0
],
self
.
users
[
1
])
software
=
os
.
path
.
join
(
self
.
software
,
'drupal'
)
#Drupal SR must exist in SR folder
response
=
self
.
loadJson
(
self
.
app
.
post
(
'/setCurrentProject'
,
response
=
loadJson
(
self
.
app
.
post
(
'/setCurrentProject'
,
data
=
dict
(
path
=
software
),
follow_redirects
=
True
))
self
.
assertEqual
(
response
[
'result'
],
""
)
...
...
slapos/runner/utils.py
View file @
c3ad77a6
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# pylint: disable-msg=W0311,C0301,C0103,C0111,W0141,W0142
import
hashlib
import
md5
import
logging
import
multiprocessing
import
re
import
signal
import
shutil
import
string
import
os
import
subprocess
import
time
...
...
@@ -45,7 +46,7 @@ html_escape_table = {
def
html_escape
(
text
):
"""Produce entities within text."""
return
""
.
join
(
html_escape_table
.
get
(
c
,
c
)
for
c
in
text
)
return
""
.
join
(
html_escape_table
.
get
(
c
,
c
)
for
c
in
text
)
def
getSession
(
config
):
"""
...
...
@@ -258,7 +259,6 @@ def startProxy(config):
def
stopProxy
(
config
):
"""Stop Slapproxy server"""
killRunningProcess
(
config
,
'proxy.pid'
)
pass
def
removeProxyDb
(
config
):
...
...
@@ -431,7 +431,7 @@ def getSlapStatus(config):
if
partition_list
:
for
i
in
xrange
(
0
,
int
(
config
[
'partition_amount'
])):
slappart_id
=
'%s%s'
%
(
"slappart"
,
i
)
if
not
[
x
[
0
]
for
x
in
partition_list
if
slappart_id
==
x
[
0
]]:
if
not
[
x
[
0
]
for
x
in
partition_list
if
slappart_id
==
x
[
0
]]:
partition_list
.
append
((
slappart_id
,
[]))
return
partition_list
...
...
@@ -444,7 +444,7 @@ def removeInstanceRoot(config):
"""Clean instance directory and stop all its running process"""
if
os
.
path
.
exists
(
config
[
'instance_root'
]):
svcStopAll
(
config
)
for
root
,
dirs
,
files
in
os
.
walk
(
config
[
'instance_root'
]):
for
root
,
dirs
,
_
in
os
.
walk
(
config
[
'instance_root'
]):
for
fname
in
dirs
:
fullPath
=
os
.
path
.
join
(
root
,
fname
)
if
not
os
.
access
(
fullPath
,
os
.
W_OK
)
:
...
...
@@ -501,11 +501,11 @@ def getFolderContent(config, folder):
Returns:
Html formated string or error message when fail.
"""
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
try:
folder = str(folder)
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
d
=
urllib.unquote(folder)
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
d
=
urllib.unquote(folder)
realdir = realpath(config, d)
if not realdir:
r.append('
Could
not
load
directory
:
Permission
denied
')
...
...
@@ -515,14 +515,14 @@ def getFolderContent(config, folder):
for f in ldir:
if f.startswith('
.
'): #do not displays this file/folder
continue
ff
=os.path.join(d,
f)
if os.path.isdir(os.path.join(realdir,f)):
r.append('
<
li
class
=
"directory collapsed"
><
a
href
=
"#%s"
rel
=
"%s/"
>%
s
</
a
></
li
>
' % (ff, ff,f))
ff
= os.path.join(d,
f)
if os.path.isdir(os.path.join(realdir,
f)):
r.append('
<
li
class
=
"directory collapsed"
><
a
href
=
"#%s"
rel
=
"%s/"
>%
s
</
a
></
li
>
' % (ff, ff,
f))
else:
e
=
os.path.splitext(f)[1][1:] # get .ext and remove dot
r.append('
<
li
class
=
"file ext_%s"
><
a
href
=
"#%s"
rel
=
"%s"
>%
s
</
a
></
li
>
' % (e, ff,
ff,
f))
e
=
os.path.splitext(f)[1][1:] # get .ext and remove dot
r.append('
<
li
class
=
"file ext_%s"
><
a
href
=
"#%s"
rel
=
"%s"
>%
s
</
a
></
li
>
' % (e, ff,
ff,
f))
r.append('
</
ul
>
')
except Exception
,
e:
except Exception
as
e:
r.append('
Could
not
load
directory
:
%
s
' % str(e))
r.append('
</
ul
>
')
return jsonify(result=''.join(r))
...
...
@@ -538,11 +538,11 @@ def getFolder(config, folder):
Returns:
Html formated string or error message when fail.
"""
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
try:
folder = str(folder)
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
d
=
urllib.unquote(folder)
r
=
['
<
ul
class
=
"jqueryFileTree"
style
=
"display: none;"
>
']
d
=
urllib.unquote(folder)
realdir = realpath(config, d)
if not realdir:
r.append('
Could
not
load
directory
:
Permission
denied
')
...
...
@@ -552,11 +552,11 @@ def getFolder(config, folder):
for f in ldir:
if f.startswith('
.
'): #do not display this file/folder
continue
ff
=os.path.join(d,
f)
if os.path.isdir(os.path.join(realdir,f)):
ff
= os.path.join(d,
f)
if os.path.isdir(os.path.join(realdir,
f)):
r.append('
<
li
class
=
"directory collapsed"
><
a
href
=
"#%s"
rel
=
"%s/"
>%
s
</
a
></
li
>
' % (ff, ff, f))
r.append('
</
ul
>
')
except Exception
,
e:
except Exception
as
e:
r.append('
Could
not
load
directory
:
%
s
' % str(e))
r.append('
</
ul
>
')
return jsonify(result=''.join(r))
...
...
@@ -634,7 +634,7 @@ def newSoftware(folder, config, session):
else:
json = "Bad folder or Directory '" + folder +
\
"' already exist, please enter a new name for your software"
except Exception
,
e:
except Exception
as
e:
json = "Can not create your software, please try again! : " + str(e)
if os.path.exists(folderPath):
shutil.rmtree(folderPath)
...
...
@@ -652,8 +652,8 @@ def getProjectTitle(config):
conf = os.path.join(config['
etc_dir
'], ".project")
if os.path.exists(conf):
project = open(conf, "r").read().split("/")
software = project[
len(project) -
2]
return
software + " (" + string.join(project[:(len(project) - 2)], '
/
') + ")"
software = project[
-
2]
return
'
%
s
(
%
s
)
' % (software, '
/
'.join(project[:-2]))
return "No Profile"
def getSoftwareReleaseName(config):
...
...
@@ -661,7 +661,7 @@ def getSoftwareReleaseName(config):
sr_profile = os.path.join(config['
etc_dir
'], ".project")
if os.path.exists(sr_profile):
project = open(sr_profile, "r").read().split("/")
software = project[
len(project) -
2]
software = project[
-
2]
return software.replace('
', '
_
')
return "No_name"
...
...
@@ -704,14 +704,14 @@ def tail(f, lines=20):
data.insert(0, f.read(BUFSIZ))
else:
# file too small, start from begining
f.seek(0,0)
f.seek(0,
0)
# only read what was not read
data.insert(0, f.read(bytes))
linesFound = data[0].count('
\
n
')
size -= linesFound
bytes -= BUFSIZ
block -= 1
return
string.join(''.join(data).splitlines()[-lines:], '
\
n
'
)
return
'
\
n
'.join(''.join(data).splitlines()[-lines:]
)
def readFileFrom(f, lastPosition):
"""
...
...
@@ -735,7 +735,7 @@ def readFileFrom(f, lastPosition):
else:
margin = abs(block*BUFSIZ) - size
if length < BUFSIZ:
f.seek(0,0)
f.seek(0,
0)
else:
seek = block * BUFSIZ + margin
f.seek(seek, 2)
...
...
@@ -749,7 +749,7 @@ def isText(file):
"""Return True if the mimetype of file is Text"""
if not os.path.exists(file):
return False
text_range = ''.join(map(chr, [7,
8,9,10,12,13,
27] + range(0x20, 0x100)))
text_range = ''.join(map(chr, [7,
8, 9, 10, 12, 13,
27] + range(0x20, 0x100)))
is_binary_string = lambda bytes: bool(bytes.translate(None, text_range))
try:
return not is_binary_string(open(file).read(1024))
...
...
@@ -762,7 +762,7 @@ def md5sum(file):
return False
try:
fh = open(file, 'rb')
m =
hashlib
.md5()
m =
md5
.md5()
while True:
data = fh.read(8192)
if not data:
...
...
@@ -805,14 +805,14 @@ def readParameters(path):
if os.path.exists(path):
try:
xmldoc = xml.dom.minidom.parse(path)
obj
ect
= {}
obj = {}
for elt in xmldoc.childNodes:
sub_obj
ect
= {}
sub_obj = {}
for subnode in elt.childNodes:
if subnode.nodeType != subnode.TEXT_NODE:
sub_obj
ect
[str(subnode.getAttribute('
id
'))] = subnode.childNodes[0].data #.decode('
utf
-
8
').decode('
utf
-
8
')
obj
ect[str(elt.tagName)] = sub_object
return obj
ect
sub_obj[str(subnode.getAttribute('
id
'))] = subnode.childNodes[0].data #.decode('
utf
-
8
').decode('
utf
-
8
')
obj
[str(elt.tagName)] = sub_obj
return obj
except Exception, e:
return str(e)
else:
...
...
slapos/runner/views.py
View file @
c3ad77a6
# -*- coding: utf-8 -*-
# vim: set et sts=2:
# pylint: disable-msg=W0311,C0301,C0103,C0111
import
os
import
shutil
...
...
@@ -16,7 +18,7 @@ from slapos.runner.utils import (checkSoftwareFolder, configNewSR, getFolder, ge
removeInstanceRoot
,
removeProxyDb
,
removeSoftwareByName
,
runInstanceWithLock
,
runSoftwareWithLock
,
saveSession
,
svcStartStopProcess
,
svcStopAll
,
tail
,
updateInstanceParameter
)
from
slapos.runner.fileBrowser
import
f
ileBrowser
from
slapos.runner.fileBrowser
import
F
ileBrowser
from
slapos.runner.gittools
import
(
cloneRepo
,
gitStatus
,
switchBranch
,
addBranch
,
getDiff
,
gitPush
,
gitPull
)
...
...
@@ -25,7 +27,7 @@ app = Flask(__name__)
app
.
config
[
'MAX_CONTENT_LENGTH'
]
=
20
*
1024
*
1024
auth
=
Auth
(
app
,
login_url_name
=
'login'
)
auth
.
user_timeout
=
0
file_request
=
f
ileBrowser
(
app
.
config
)
file_request
=
F
ileBrowser
(
app
.
config
)
# Setup default flask (werkzeug) parser
import
logging
...
...
@@ -73,7 +75,7 @@ def myAccount():
@
app
.
route
(
"/dologout"
)
def
dologout
():
user_data
=
logout
()
_
=
logout
()
return
redirect
(
url_for
(
'login'
))
@
login_required
()
...
...
@@ -108,6 +110,7 @@ def inspectSoftware():
result
=
""
else
:
result
=
app
.
config
[
'software_root'
]
# XXX not used??
return
render_template
(
'runResult.html'
,
softwareRoot
=
'software_link/'
,
softwares
=
loadSoftwareRList
(
app
.
config
))
...
...
@@ -173,11 +176,11 @@ def supervisordStatus():
html
=
"<tr><th>Partition and Process name</th><th>Status</th><th>Process PID </th><th> UpTime</th><th></th></tr>"
for
item
in
result
:
html
+=
"<tr>"
html
+=
"<td class='first'><b><a href='"
+
url_for
(
'tailProcess'
,
process
=
item
[
0
])
+
"'>"
+
item
[
0
]
+
"</a></b></td>"
html
+=
"<td align='center'><a href='"
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
item
[
1
])
+
"'>"
+
item
[
1
]
+
"</a></td>"
html
+=
"<td align='center'>"
+
item
[
3
]
+
"</td><td>"
+
item
[
5
]
+
"</td>"
html
+=
"<td align='center'><a href='"
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
'RESTART'
)
+
"'>Restart</a></td>"
html
+=
"</tr>"
html
+=
"<td class='first'><b><a href='"
+
url_for
(
'tailProcess'
,
process
=
item
[
0
])
+
"'>"
+
item
[
0
]
+
"</a></b></td>"
html
+=
"<td align='center'><a href='"
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
item
[
1
])
+
"'>"
+
item
[
1
]
+
"</a></td>"
html
+=
"<td align='center'>"
+
item
[
3
]
+
"</td><td>"
+
item
[
5
]
+
"</td>"
html
+=
"<td align='center'><a href='"
+
url_for
(
'startStopProccess'
,
process
=
item
[
0
],
action
=
'RESTART'
)
+
"'>Restart</a></td>"
html
+=
"</tr>"
return
jsonify
(
code
=
1
,
result
=
html
)
@
login_required
()
...
...
@@ -295,7 +298,7 @@ def createFile():
request
.
form
[
'type'
]
+
": Permission Denied"
)
try
:
if
request
.
form
[
'type'
]
==
"file"
:
f
=
open
(
path
,
'w'
).
write
(
" "
)
open
(
path
,
'w'
)
else
:
os
.
mkdir
(
path
)
return
jsonify
(
code
=
1
,
result
=
""
)
...
...
@@ -575,7 +578,7 @@ def fileBrowser():
except
:
abort
(
404
)
elif
opt
==
9
:
truncateTo
=
int
(
request
.
form
.
get
(
'truncate'
,
'0'
))
truncateTo
=
int
(
request
.
form
.
get
(
'truncate'
,
'0'
))
# XXX not used??
result
=
file_request
.
readFile
(
dir
,
filename
)
elif
opt
==
11
:
#Upload file
...
...
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