Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyworkflow/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ def getCurrentProtocolView(self):

return self._protocolViews[viewKey]

def create(self, runsView=1, readOnly=False, hostsConf=None, protocolsConf=None, chdir=True, workflow=None):
def create(self, runsView=1, readOnly=False, hostsConf=None,
protocolsConf=None, chdir=True, workflow=None):

"""Prepare all required paths and files to create a new project.
Params:
hosts: a list of configuration hosts associated to this projects
Expand Down
4 changes: 1 addition & 3 deletions pyworkflow/web/app/views_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from views_util import loadProject, getResourceCss, getResourceIcon, getResourceJs, \
getServiceManager, PROJECT_NAME, SERVICE_NAME, \
getVarFromRequest, CTX_PROJECT_PATH, CTX_PROJECT_NAME, WORKFLOW, MODE

from workflowarchive.models import Workflow

def projects(request):
from pyworkflow.utils.utils import prettyDate
Expand All @@ -66,9 +66,7 @@ def projects(request):


def workflows(request):

workflows = getWorkflowsList()

# Annotate existence of projects (hashed)
manager = getServiceManager(None)

Expand Down
5 changes: 5 additions & 0 deletions pyworkflow/web/pages/resources/css/projects_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
letter-spacing: 0.3em;
text-align: center;
}
.workFlowForm {
list-style: none;
margin: 10px;
}
.projList {
list-style: none;
margin: 10px;
Expand Down Expand Up @@ -52,6 +56,7 @@
overflow-x: hidden;
width: 100%;
}

li:nth-child(odd) {
background-color: #FFF;
padding: 0px 10px;
Expand Down
20 changes: 13 additions & 7 deletions pyworkflow/web/pages/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

WEB_CONF = pwconfig.loadWebConf()

# DEBUG = True
DEBUG = WEB_CONF['DEBUG']
DEBUG = True
#DEBUG = WEB_CONF['DEBUG']
TEMPLATE_DEBUG = DEBUG

ADMINS = (
Expand Down Expand Up @@ -105,8 +105,10 @@

# Additional locations of static files
WS_ROOT = os.path.join(pw.HOME, 'web', 'webtools')
serviceFolders = [os.path.join(WS_ROOT, f) for f in os.listdir(WS_ROOT) if os.path.isdir(os.path.join(WS_ROOT, f))]
staticDirs = [os.path.join(pw.HOME, 'web', 'pages')] + serviceFolders
serviceFolders = [os.path.join(WS_ROOT, f) for f in os.listdir(WS_ROOT)
if os.path.isdir(os.path.join(WS_ROOT, f))]
staticDirs = [os.path.join(pw.HOME, 'web', 'pages')] \
+ serviceFolders

# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
Expand All @@ -123,7 +125,9 @@
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
templateDirs = [os.path.join(DIRECTORY_PROJECT)] + serviceFolders
TEMPLATE_DIRS = tuple([os.path.join(d, 'templates') for d in templateDirs])
templateDirs += [os.path.join(pw.HOME, 'web', 'workflowarchive')]

TEMPLATE_DIRS = tuple([os.path.join(d, 'templates') for d in templateDirs])

# TEMPLATE_DIRS = (
# os.path.join(DIRECTORY_PROJECT, 'templates'),
Expand Down Expand Up @@ -179,7 +183,9 @@
# 'django.contrib.admindocs',
# 'gunicorn',
'app',
'resumable'
'resumable',
'workflowarchive',# workflow archive project
'tastypie',# web services support
]

try:
Expand Down Expand Up @@ -235,4 +241,4 @@
EMAIL_HOST = EMAIL_CONF['EMAIL_HOST']
EMAIL_PORT = EMAIL_CONF['EMAIL_PORT']
EMAIL_HOST_USER = EMAIL_CONF['EMAIL_HOST_USER']
EMAIL_HOST_PASSWORD = EMAIL_CONF['EMAIL_HOST_PASSWORD']
EMAIL_HOST_PASSWORD = EMAIL_CONF['EMAIL_HOST_PASSWORD']
17 changes: 13 additions & 4 deletions pyworkflow/web/pages/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from pyworkflow.web import app
from pyworkflow.web.app import views_util, views_home, views_showj
from pyworkflow.web.app.views_management import ScipionResumableUploadView

#from pyworkflow.web.workflowarchive import views as views_workflowarchive
admin.autodiscover()
from django.conf import settings
from pyworkflow.web.pages.settings import WS_ROOT, serviceFolders
from django.views.generic import TemplateView

from django.conf.urls import include
# ===============================================================================
# URL ASSOCIATION
# ===============================================================================
Expand All @@ -27,7 +27,11 @@
#PROJECT (CONTENT, RUNTABLE AND GRAPH)
url(r'^projects/', 'app.views_project.projects'),
url(r'^create_project/$', 'app.views_project.create_project'),
#INFO: ROB next should finish in $?
url(r'^workflows/', 'app.views_project.workflows'),
#TODO: ROB: I do not like to put all urls together
# I think they should be at their respective applications
url(r'^workflowarchive/', include('workflowarchive.urls')),
url(r'^delete_project/$', 'app.views_project.delete_project'),
url(r'^project_content/$', 'app.views_project.project_content'),
url(r'^get_protocols/$', 'app.views_project.get_protocols'),
Expand Down Expand Up @@ -89,8 +93,9 @@
#SHOWJ
url(r'^showj/$', app.views_showj.showj), #Load showj web
url(r'^update_session_table/$', 'app.views_showj.updateSessionTable'),
url(r'^jsmol/$', 'app.views_showj.jsmol'),
url(r'^get_chimera_html/$', 'app.views_showj.get_chimera_html'),
#TODO: ROB the following two modules do not exists!?
####url(r'^jsmol/$', 'app.views_showj.jsmol'),
####url(r'^get_chimera_html/$', 'app.views_showj.get_chimera_html'),

#BROWSER & UPLOAD FILES
url(r'^upload/', 'app.views_management.upload'),
Expand Down Expand Up @@ -131,3 +136,7 @@
handler500 = "app.views_util.handle500error"

urlpatterns = patterns(*mainUrls)

#TODO ROB need css files
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
72 changes: 72 additions & 0 deletions pyworkflow/web/workflowarchive/HtmlTest/workflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[
{
"object.className": "ProtStress",
"object.id": "103",
"object.label": "scipion - stress 3",
"object.comment": "",
"runName": null,
"runMode": 0,
"noCpu": 0,
"noMem": 2,
"amountMem": 256,
"noIO": 0,
"timeout": 60,
"delay": 0,
"extraParams": " "
},
{
"object.className": "ProtMonitorSystem",
"object.id": "200",
"object.label": "scipion - system_monitor",
"object.comment": "",
"runName": null,
"runMode": 0,
"inputProtocols": [
"103"
],
"samplingInterval": 1,
"cpuAlert": 90.0,
"memAlert": 90.0,
"swapAlert": 100.0,
"monitorTime": 300.0,
"doMail": false,
"emailFrom": "from@from.fakeadress.com",
"emailTo": "to@to.fakeadress.com",
"smtp": "smtp.fakeadress.com"
},
{
"object.className": "ProtStress",
"object.id": "467",
"object.label": "scipion - stress 3 (copy)",
"object.comment": "",
"runName": null,
"runMode": 0,
"noCpu": 0,
"noMem": 2,
"amountMem": 256,
"noIO": 0,
"timeout": 60,
"delay": 0,
"extraParams": " "
},
{
"object.className": "ProtMonitorSystem",
"object.id": "499",
"object.label": "scipion - system_monitor (copy)",
"object.comment": "",
"runName": null,
"runMode": 0,
"inputProtocols": [
"467"
],
"samplingInterval": 1,
"cpuAlert": 90.0,
"memAlert": 90.0,
"swapAlert": 100.0,
"monitorTime": 300.0,
"doMail": false,
"emailFrom": "from@from.fakeadress.com",
"emailTo": "to@to.fakeadress.com",
"smtp": "smtp.fakeadress.com"
}
]
131 changes: 131 additions & 0 deletions pyworkflow/web/workflowarchive/HtmlTest/workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
import string, random
import tempfile

example_content="""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://0.0.0.0:8000/" />
<title>workflow</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">workflow</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/workflowarchive/</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=id_workflowName</td>
<td>workflow_random</td>
</tr>
<tr>
<td>type</td>
<td>id=id_description</td>
<td>Here goes a description of the tests</td>
</tr>
<tr>
<td>type</td>
<td>id=id_file</td>
<td>/home/roberto/Scipion/scipion-web/pyworkflow/web/workflowarchive/HtmlTest/workflow.json</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=button[type=&quot;submit&quot;]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>css=div.workFlowForm</td>
<td>workflow uploaded </td>
</tr>

</tbody></table>
</body>
</html>"""

class Workflow(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.implicitly_wait(30)
self.base_url = "http://0.0.0.0:8000"
self.verificationErrors = []
self.accept_next_alert = True
self.workflowName= "wf_" + ''.join(random.choice(string.lowercase) for x in range(16))
self.createJsonFile()

def createJsonFile(self):
self.f = tempfile.NamedTemporaryFile(delete=False)
self.f.write(example_content)
self.f.close()

def test_workflow(self):
#connect and paint upload workflow form
driver = self.driver
driver.get(self.base_url + "/workflowarchive/")

#fill in form using a random workflow name
driver.find_element_by_id("id_workflowName").clear()
driver.find_element_by_id("id_workflowName").send_keys(self.workflowName)
driver.find_element_by_id("id_description").clear()
driver.find_element_by_id("id_description").send_keys("Here goes a description of the tests")
driver.find_element_by_id("id_file").clear()
driver.find_element_by_id("id_file").send_keys(self.f.name)

#wait two second before sending workflow
time.sleep(2)
driver.find_element_by_css_selector("button[type=\"submit\"]").click()

# chek that resul contain magic string
import re
returnedText = driver.find_element_by_css_selector("div.workFlowForm").text
text_found = re.search('workflow uploaded', returnedText)
self.assertNotEqual(text_found, None)
text_found = re.search('hi you', returnedText)
self.assertEqual(text_found, None)

# wait a bit before clossing window
time.sleep(3)
os.unlink(self.f.name)


def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True

def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True

def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
unittest.main()
Loading