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
Lisa Casino
slapos.toolbox
Commits
f21b532e
Commit
f21b532e
authored
Jul 26, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: avoid useless \' escaping
parent
5f34b3f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+12
-12
No files found.
slapos/runner/fileBrowser.py
View file @
f21b532e
...
@@ -15,7 +15,7 @@ from slapos.runner.utils import realpath, tail, isText
...
@@ -15,7 +15,7 @@ from slapos.runner.utils import realpath, tail, isText
class
FileBrowser
(
object
):
class
FileBrowser
(
object
):
"""This class contain all base
s function
for file browser"""
"""This class contain all base
functions
for file browser"""
def
__init__
(
self
,
config
):
def
__init__
(
self
,
config
):
self
.
config
=
config
self
.
config
=
config
...
@@ -67,9 +67,9 @@ class FileBrowser(object):
...
@@ -67,9 +67,9 @@ class FileBrowser(object):
folder = os.path.join(realdir, filename)
folder = os.path.join(realdir, filename)
if not os.path.exists(folder):
if not os.path.exists(folder):
os.mkdir(folder, 0744)
os.mkdir(folder, 0744)
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
else:
else:
return
'{result:
\
'
0
\
'
}'
return
"
{
result
:
'0'
}
"
def makeFile(self, dir, filename):
def makeFile(self, dir, filename):
"""Create a file in a directory dir taken"""
"""Create a file in a directory dir taken"""
...
@@ -77,9 +77,9 @@ class FileBrowser(object):
...
@@ -77,9 +77,9 @@ class FileBrowser(object):
fout = os.path.join(realdir, filename)
fout = os.path.join(realdir, filename)
if not os.path.exists(fout):
if not os.path.exists(fout):
open(fout, 'w')
open(fout, 'w')
return
'var responce = {result:
\
'
1
\
'
}'
return
"
var
responce
=
{
result
:
'1'
}
"
else:
else:
return
'{result:
\
'
0
\
'
}'
return
"
{
result
:
'0'
}
"
def deleteItem(self, dir, files):
def deleteItem(self, dir, files):
"""Delete a list of files or directories"""
"""Delete a list of files or directories"""
...
@@ -102,7 +102,7 @@ class FileBrowser(object):
...
@@ -102,7 +102,7 @@ class FileBrowser(object):
os.unlink(file)
os.unlink(file)
except Exception as e:
except Exception as e:
return str(e)
return str(e)
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
def copyItem(self, dir, files, del_source=False):
def copyItem(self, dir, files, del_source=False):
"""Copy a list of files or directory to dir"""
"""Copy a list of files or directory to dir"""
...
@@ -129,7 +129,7 @@ class FileBrowser(object):
...
@@ -129,7 +129,7 @@ class FileBrowser(object):
os.unlink(realfile)
os.unlink(realfile)
except Exception as e:
except Exception as e:
return str(e)
return str(e)
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
def rename(self, dir, filename, newfilename):
def rename(self, dir, filename, newfilename):
"""Rename file or directory to dir/filename"""
"""Rename file or directory to dir/filename"""
...
@@ -140,7 +140,7 @@ class FileBrowser(object):
...
@@ -140,7 +140,7 @@ class FileBrowser(object):
tofile = os.path.join(realdir, newfilename)
tofile = os.path.join(realdir, newfilename)
if not os.path.exists(tofile):
if not os.path.exists(tofile):
os.rename(realfile, tofile)
os.rename(realfile, tofile)
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def copyAsFile(self, dir, filename, newfilename):
def copyAsFile(self, dir, filename, newfilename):
...
@@ -152,7 +152,7 @@ class FileBrowser(object):
...
@@ -152,7 +152,7 @@ class FileBrowser(object):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
if not os.path.exists(tofile):
if not os.path.exists(tofile):
shutil.copy(fromfile, tofile)
shutil.copy(fromfile, tofile)
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def uploadFile(self, dir, files):
def uploadFile(self, dir, files):
...
@@ -163,7 +163,7 @@ class FileBrowser(object):
...
@@ -163,7 +163,7 @@ class FileBrowser(object):
filename = werkzeug.secure_filename(files[file].filename)
filename = werkzeug.secure_filename(files[file].filename)
if not os.path.exists(os.path.join(dir, filename)):
if not os.path.exists(os.path.join(dir, filename)):
files[file].save(os.path.join(realdir, filename))
files[file].save(os.path.join(realdir, filename))
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
def downloadFile(self, dir, filename):
def downloadFile(self, dir, filename):
"""Download file dir/filename"""
"""Download file dir/filename"""
...
@@ -192,7 +192,7 @@ class FileBrowser(object):
...
@@ -192,7 +192,7 @@ class FileBrowser(object):
else:
else:
zip.write(fromzip)
zip.write(fromzip)
zip.close()
zip.close()
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def unzipFile(self, dir, filename, newfilename):
def unzipFile(self, dir, filename, newfilename):
...
@@ -210,7 +210,7 @@ class FileBrowser(object):
...
@@ -210,7 +210,7 @@ class FileBrowser(object):
# zip.extractall(target)
# zip.extractall(target)
#else:
#else:
# zip.extract(member[0], newfilename)
# zip.extract(member[0], newfilename)
return
'{result:
\
'
1
\
'
}'
return
"
{
result
:
'1'
}
"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
def readFile(self, dir, filename, truncate=False):
def readFile(self, dir, filename, truncate=False):
...
...
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