Commit f21b532e authored by Marco Mariani's avatar Marco Mariani

runner: avoid useless \' escaping

parent 5f34b3f6
...@@ -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 bases 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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment