Skip to content
Merged
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
13 changes: 11 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ you can use the script::
:src: ../WorkflowWebTools/test/config.yml
:analyzer: shell-script

Maintaining the Web Tools
-------------------------
Maintaining the Python Backend
------------------------------

For developers wishing to make adjustments to the modules or
anyone else who wants to understand some of the backend of the server,
Expand Down Expand Up @@ -185,6 +185,15 @@ Show Log
.. automodule:: WorkflowWebTools.showlog
:members:

JavaScript and Mako User Interface
----------------------------------

Some documentation of the JavaScript used on the webpages are given below.

.. autoanysrc:: phony
:src: ../WorkflowWebTools/runserver/static/js/*.js
:analyzer: js

WorkflowWebTools Forks' Build Statuses
--------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion clusterworkflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.. math::

\\mathrm{distance} = \\frac{d}{\\sqrt{2} |\\vec{v}|} +
2.0 w \\left(\\frac{|\\vec{v}|}{|\\vec{v}| + m} - 0.5\\right)
2 w \\left(\\frac{|\\vec{v}|}{|\\vec{v}| + m} - 0.5\\right)

*d* is the 'distance' parameter, *w* is the 'width' parameter,
and *m* is the 'midpoint' parameter set in the ``config.yml``.
Expand Down
13 changes: 8 additions & 5 deletions globalerrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def __init__(self, data_location=''):

self.clusters = None
self.data_location = data_location
if not self.data_location:
self.data_location = serverconfig.all_errors_path()
self.setup()

def __del__(self):
Expand All @@ -38,18 +36,23 @@ def setup(self):

self.timestamp = time.time()

if self.data_location:
data_location = self.data_location
else:
data_location = serverconfig.all_errors_path()

# Store everything into an SQL database for fast retrival

if self.data_location.endswith('.db') and os.path.exists(self.data_location):
self.conn = sqlite3.connect(self.data_location, check_same_thread=False)
if data_location.endswith('.db') and os.path.exists(data_location):
self.conn = sqlite3.connect(data_location, check_same_thread=False)
curs = self.conn.cursor()

else:
self.conn = sqlite3.connect(':memory:', check_same_thread=False)
curs = self.conn.cursor()

errorutils.create_table(curs)
errorutils.add_to_database(curs, self.data_location)
errorutils.add_to_database(curs, data_location)

def get_all(column):
"""Get list of all unique entries in the database
Expand Down
72 changes: 68 additions & 4 deletions manageactions.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
"""
Module to manage actions of WorkflowWebTools.
"""Module to manage actions of WorkflowWebTools.

:author: Daniel Abercrombie <dabercro@mit.edu>
"""

import os
import json
import glob


from datetime import datetime
from datetime import timedelta
from . import reasonsmanip


ACTIONS_DIRECTORY = 'actions'
"""The location to store the actions JSON files"""

def extract_reasons_params(**kwargs):
"""Extracts the reasons and parameters for an action from kwargs

Expand Down Expand Up @@ -78,8 +82,13 @@ def submitaction(user, workflows, action, **kwargs):

reasons, params = extract_reasons_params(**kwargs)

output_file_name = 'actions/{0}_{1}.json'.\
format(user, datetime.now().strftime('%Y%m%d'))
if not os.path.exists(ACTIONS_DIRECTORY):
os.makedirs(ACTIONS_DIRECTORY)

output_file_name = os.path.join(
ACTIONS_DIRECTORY, '{0}_{1}.json'.\
format(user, datetime.now().strftime('%Y%m%d'))
)

add_to_json = {}
if os.path.isfile(output_file_name):
Expand All @@ -100,3 +109,58 @@ def submitaction(user, workflows, action, **kwargs):
json.dump(add_to_json, outputfile)

return workflows, action, reasons, params


def get_prev_actions(num_days):
"""Get the keys and values of recent actions

:param int num_days: is the number of days to check for actions
:rtype: generator
"""

date = datetime.now()
date_int = int(date.strftime('%Y%m%d'))
prev_int = int((date - timedelta(num_days)).strftime('%Y%m%d'))

for match in glob.iglob(os.path.join(ACTIONS_DIRECTORY, '*.json')):
check_int = int(match.split('_')[-1].rstrip('.json'))
if prev_int <= check_int <= date_int:
with open(match, 'r') as infile:
output = json.load(infile)
for key, value in output.iteritems():
value['user'] = match.split('/')[-1].split('_')[0]
yield key, value


def get_actions(num_days):
"""Get the recent actions to be act on in dictionary form

:param int num_days: is the number of days to check for actions
:returns: A dictionary of actions, to be rendered as JSON
:rtype: dict
"""

output = {}

for key, value in get_prev_actions(num_days):
output[key] = value

return output


def get_acted_workflows(num_days):
"""Get all of the workflows that have actions assigned

:param int num_days: is the number of past days to check for actions.
This speeds up the check while not losing the
ability to look farther back in time.
:returns: a list of workflows acted on
:rtype: list
"""

workflows = []

for key, _ in get_prev_actions(num_days):
workflows.append(key)

return workflows
5 changes: 3 additions & 2 deletions manageusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ def resetpassword(code, password):


def add_user(email, username, password, url):
"""Adds the user to the users database and sends a verification email,
if the parameters are valid.
"""
Adds the user to the users database and sends a verification email,
if the parameters are valid.

:param str email: The user email to send verification to.
Make sure to check for valid domains.
Expand Down
14 changes: 0 additions & 14 deletions runserver/actions/test.json

This file was deleted.

8 changes: 8 additions & 0 deletions runserver/static/css/rotation.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ th.rotate > div {
font-size: 70%;
word-wrap: break-word;
}

.done {
background-color:#4fef4f;
}

.todo {
background-color:#ef4f4f;
}
10 changes: 7 additions & 3 deletions runserver/static/css/style.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
html {
margin:1em auto;
max-width:60em;
background-color:#efefef;
background-color:#a0a0a0;
}

body {
background-color:#ffffff;
padding:2em;
}

h1, h2, h3 {
h1, h2 {
text-align:center;
}

h3 {
background-color:#e6f7ff;
}

footer {
padding:2em;
background-color:#e6f7ff;
}
}
Loading