Commit a3c09a4b authored by Marco Mariani's avatar Marco Mariani

runner: grammar nazi

parent ab224625
......@@ -15,7 +15,7 @@ from slapos.runner.utils import realpath, tail, isText
class FileBrowser(object):
"""This class contain all base functions for file browser"""
"""This class contains all base functions for file browser"""
def __init__(self, config):
self.config = config
......@@ -115,7 +115,7 @@ class FileBrowser(object):
details = realfile.split('/')
dest = os.path.join(realdir, details[-1])
if os.path.exists(dest):
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exists')
if os.path.isdir(realfile):
shutil.copytree(realfile, dest)
if del_source:
......@@ -138,7 +138,7 @@ class FileBrowser(object):
if not os.path.exists(tofile):
os.rename(realfile, tofile)
return "{result: '1'}"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exists')
def copyAsFile(self, dir, filename, newfilename):
"""Copy file or directory to dir/filename"""
......@@ -146,14 +146,14 @@ class FileBrowser(object):
fromfile = os.path.join(realdir, filename)
tofile = os.path.join(realdir, newfilename)
if not os.path.exists(fromfile):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
raise NameError('NOT ALLOWED OPERATION : File or directory does not exist')
if not os.path.exists(tofile):
shutil.copy(fromfile, tofile)
return "{result: '1'}"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exists')
def uploadFile(self, dir, files):
"""Upload a list of file in directory dir"""
"""Upload a list of files in directory dir"""
realdir = self._realdir(dir)
for file in files:
if files[file]:
......@@ -177,7 +177,7 @@ class FileBrowser(object):
tozip = os.path.join(realdir, newfilename)
fromzip = os.path.join(realdir, filename)
if not os.path.exists(fromzip):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
raise NameError('NOT ALLOWED OPERATION : File or directory does not exist')
if not os.path.exists(tozip):
zip = zipfile.ZipFile(tozip, 'w', zipfile.ZIP_DEFLATED)
if os.path.isdir(fromzip):
......@@ -190,7 +190,7 @@ class FileBrowser(object):
zip.write(fromzip)
zip.close()
return "{result: '1'}"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exists')
def unzipFile(self, dir, filename, newfilename):
"""Extract a zipped archive"""
......@@ -198,7 +198,7 @@ class FileBrowser(object):
target = os.path.join(realdir, newfilename)
archive = os.path.join(realdir, filename)
if not os.path.exists(archive):
raise NameError('NOT ALLOWED OPERATION : File or directory not exist')
raise NameError('NOT ALLOWED OPERATION : File or directory does not exist')
if not os.path.exists(target):
zip = zipfile.ZipFile(archive)
#member = zip.namelist()
......@@ -208,7 +208,7 @@ class FileBrowser(object):
#else:
# zip.extract(member[0], newfilename)
return "{result: '1'}"
raise NameError('NOT ALLOWED OPERATION : File or directory already exist')
raise NameError('NOT ALLOWED OPERATION : File or directory already exists')
def readFile(self, dir, filename, truncate=False):
"""Read file dir/filename and return content"""
......
......@@ -12,19 +12,19 @@ from flask import jsonify
def cloneRepo(data):
"""Clonne a repository
"""Clone a repository
Args:
data: a dictionary of parameters to use:
data['path'] is the path of the new project
data['repo'] is the url of the repository to be cloned
data['email'] is the user email
data['email'] is the user's email
data['user'] is the name of the user
Returns:
a jsonify data"""
workDir = data['path']
if not workDir:
return jsonify(code=0,
result="Can not create project folder: Permission Denied")
result="Cannot create project folder: Permission Denied")
code = 0
json = ""
try:
......@@ -46,7 +46,7 @@ def cloneRepo(data):
def gitStatus(project):
"""Run git status and return status of specified project folder
Args:
project: path of the projet ti get status
project: path of the projet to get status
Returns:
a parsed string that contains the result of git status"""
code = 0
......@@ -146,7 +146,7 @@ def gitPush(project, msg):
git.push('origin', current_branch)
code = 1
else:
json = "Nothing to be commited"
json = "Nothing to commit"
code = 1
except Exception as e:
if undo_commit:
......
......@@ -9,7 +9,7 @@ SLAPRUNNER_PROCESS_LIST = []
class Popen(subprocess.Popen):
"""
Extension of Popen to launch and kill process in a clean way
Extension of Popen to launch and kill processes in a clean way
"""
def __init__(self, *args, **kwargs):
"""
......@@ -28,7 +28,7 @@ class Popen(subprocess.Popen):
def kill(self, sig=signal.SIGTERM, recursive=False):
"""
Kill process and all its descendant if recursive
Kill process and all its descendants if recursive
"""
if self.poll() is None:
if recursive:
......@@ -83,7 +83,7 @@ def isRunning(name):
def killRunningProcess(name, recursive=False):
"""
Kill all process with name
Kill all processes with a given name
"""
for process in SLAPRUNNER_PROCESS_LIST:
if process.name == name:
......@@ -92,7 +92,7 @@ def killRunningProcess(name, recursive=False):
def handler(sig, frame):
"""
Signal handler to kill all process
Signal handler to kill all processes
"""
pid = os.getpid()
os.kill(-pid, sig)
......
......@@ -5,12 +5,12 @@
import argparse
import ConfigParser
import datetime
import hashlib
import json
import os
import shutil
import time
import unittest
import hashlib
from slapos.runner.utils import (getProfilePath, getSession, isInstanceRunning,
isSoftwareRunning, startProxy)
......@@ -174,7 +174,7 @@ class SlaprunnerTestCase(unittest.TestCase):
self.assertEqual(proxy, status)
def setupProjectFolder(self, withSoftware=False):
"""Helper for create a project folder as for slapos.git"""
"""Helper to create a project folder as for slapos.git"""
base = os.path.join(self.app.config['workspace'], 'slapos')
software = os.path.join(base, 'software')
os.mkdir(base)
......@@ -193,7 +193,7 @@ class SlaprunnerTestCase(unittest.TestCase):
'w').write(sr)
def setupSoftwareFolder(self):
"""Helper for setup compiled software release dir"""
"""Helper to setup compiled software release dir"""
self.setupProjectFolder(withSoftware=True)
md5 = hashlib.md5(os.path.join(self.app.config['workspace'],
"slapos/software/slaprunner-test",
......@@ -218,7 +218,7 @@ class SlaprunnerTestCase(unittest.TestCase):
#Begin test case here
def test_wrong_login(self):
"""Test Login user before create session. This should return error value"""
"""Test Login user before create session. This should return an error value"""
response = self.login(self.users[0], self.users[1])
#redirect to config account page
assert "<h2 class='title'>Your personal information</h2><br/>" in response.data
......@@ -249,7 +249,7 @@ class SlaprunnerTestCase(unittest.TestCase):
assert "<h2>Login to Slapos Web Runner</h2>" in result.data
def test_updateAccount(self):
"""test Update accound, this need user to loging in"""
"""test Update accound, this needs the user to log in"""
self.setAccount()
response = loadJson(self.updateAccount(self.updateUser, self.rcode))
self.assertEqual(response['code'], 1)
......
......@@ -3,12 +3,10 @@
# pylint: disable-msg=W0311,C0301,C0103,C0111,W0141,W0142
import md5
import logging
import md5
import multiprocessing
import re
from slapos.runner.process import Popen, isRunning, killRunningProcess
from slapos.htpasswd import HtpasswdFile
import shutil
import os
import time
......@@ -18,6 +16,8 @@ from xml.dom import minidom
import xml_marshaller
from flask import jsonify
from slapos.runner.process import Popen, isRunning, killRunningProcess
from slapos.htpasswd import HtpasswdFile
import slapos.slap
# Setup default flask (werkzeug) parser
......
......@@ -490,8 +490,7 @@ def slapgridResult():
'position': 0,
'truncated': False
}
if request.form['log'] == "software" or \
request.form['log'] == "instance":
if request.form['log'] in ['software', 'instance']:
log_file = request.form['log'] + "_log"
if os.path.exists(app.config[log_file]):
log_result = readFileFrom(open(app.config[log_file]),
......
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