r5500 - trunk/cumin/python/cumin/grid
by croberts@fedoraproject.org
Author: croberts
Date: 2012-10-09 17:36:12 +0000 (Tue, 09 Oct 2012)
New Revision: 5500
Modified:
trunk/cumin/python/cumin/grid/submitter.py
Log:
Removing unnecessary checkboxes from submitter list. Also adding the selectable field search utility to the submitter list.
Modified: trunk/cumin/python/cumin/grid/submitter.py
===================================================================
--- trunk/cumin/python/cumin/grid/submitter.py 2012-10-09 15:27:00 UTC (rev 5499)
+++ trunk/cumin/python/cumin/grid/submitter.py 2012-10-09 17:36:12 UTC (rev 5500)
@@ -43,15 +43,33 @@
frame = "main.grid.scheduler.submitter"
col = ObjectLinkColumn(app, "name", cls.Name, cls._id, frame)
self.add_column(col)
- self.add_search_filter(col)
self.add_attribute_column(cls.Machine)
self.add_attribute_column(cls.ScheddName)
self.add_attribute_column(cls.IdleJobs)
self.add_attribute_column(cls.RunningJobs)
self.add_attribute_column(cls.HeldJobs)
+
+ self.field_param = StringParameter(app, "field_param")
+ self.add_parameter(self.field_param)
+
+ self.select_input = self.SubmitterFieldOptions(app, self.field_param)
+ self.add_selectable_search_filter(self.select_input)
self.enable_csv_export(scheduler)
+
+ def create_table(self, app, name, cls):
+ # avoid the checkboxes
+ return SelectableSearchObjectTable(app, name, cls)
+
+ class SubmitterFieldOptions(SelectableSearchObjectTable.SearchFieldOptions):
+ def __init__(self, app, param):
+ super(SubmitterSelector.SubmitterFieldOptions, self).__init__(app, param)
+ self.cls = app.model.com_redhat_grid.Submitter
+
+ def do_get_items(self, session):
+ return [self.cls.Name, self.cls.Machine, self.cls.ScheddName, \
+ self.cls.IdleJobs, self.cls.RunningJobs, self.cls.HeldJobs]
class SubmitterGeneralStatSet(StatSet):
def __init__(self, app, name, object):
11 years, 7 months
r5499 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-10-09 15:27:00 +0000 (Tue, 09 Oct 2012)
New Revision: 5499
Modified:
trunk/cumin/python/cumin/objectselector.py
Log:
Bringing back implicit "contains" searching for text fields (wildcard % will be inserted at beginning and end of search string if no other % are found in the string).
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2012-10-08 20:27:48 UTC (rev 5498)
+++ trunk/cumin/python/cumin/objectselector.py 2012-10-09 15:27:00 UTC (rev 5499)
@@ -454,13 +454,12 @@
self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column))
else:
post = "%"
- self.adapter.query.add_filter(self.SelectableFieldLikeFilter(sql_column))
+ if not "%" in customvalue:
+ pre = "%%"
+ else:
+ post = ""
+ self.adapter.query.add_filter(self.SelectableFieldLikeFilter(sql_column))
- if not "%" in customvalue:
- pre = type == SqlLikeFilter.CONTAINS and "%%" or ""
- else:
- post = ""
-
values[customfield] = "%s%s%s" % (pre, customvalue, post)
return values
11 years, 7 months
r5498 - in trunk/sage/python/sage: . aviary
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-10-08 20:27:48 +0000 (Mon, 08 Oct 2012)
New Revision: 5498
Modified:
trunk/sage/python/sage/aviary/aviarylocator.py
trunk/sage/python/sage/aviary/aviaryoperations.py
trunk/sage/python/sage/util.py
Log:
AviaryLocator is not handling datadir as a list like aviaryoperations.py
Modified: trunk/sage/python/sage/aviary/aviarylocator.py
===================================================================
--- trunk/sage/python/sage/aviary/aviarylocator.py 2012-10-08 15:56:13 UTC (rev 5497)
+++ trunk/sage/python/sage/aviary/aviarylocator.py 2012-10-08 20:27:48 UTC (rev 5498)
@@ -1,7 +1,7 @@
import logging
import os
-from sage.util import parse_URL
+from sage.util import parse_URL, get_datadir
from clients import OverrideClient, TransportFactory
log = logging.getLogger("sage.aviary.locator")
@@ -21,8 +21,8 @@
'''
self.transport = TransportFactory(key, cert, root_cert, domain_verify)
self.scheme, self.locator_uri = self._get_uri(locator_uri)
- self.datadir = datadir
- self.wsdl = "file:" + os.path.join(self.datadir, "aviary-locator.wsdl")
+ self.wsdl = "file:" + os.path.join(get_datadir(datadir, "locator"),
+ "aviary-locator.wsdl")
log.info("AviaryLocator: locator URL set to %s" % self.locator_uri)
def _get_uri(self, locator):
Modified: trunk/sage/python/sage/aviary/aviaryoperations.py
===================================================================
--- trunk/sage/python/sage/aviary/aviaryoperations.py 2012-10-08 15:56:13 UTC (rev 5497)
+++ trunk/sage/python/sage/aviary/aviaryoperations.py 2012-10-08 20:27:48 UTC (rev 5498)
@@ -11,7 +11,7 @@
from datetime import datetime
from threading import Lock
from suds import *
-from sage.util import CallSync, CallThread, ObjectPool, host_list
+from sage.util import CallSync, CallThread, ObjectPool, host_list, get_datadir
from aviarylocator import AviaryLocator
from clients import ClientPool, TransportFactory
@@ -226,7 +226,7 @@
- job_wsdl = "file:" + os.path.join(self.get_datadir(datadir,"job"),
+ job_wsdl = "file:" + os.path.join(get_datadir(datadir, "job"),
"aviary-job.wsdl")
self.job_client_pool = ClientPool(job_wsdl, None)
@@ -419,7 +419,7 @@
"/services/query/",
"QUERY_SERVER")
- query_wsdl = "file:" + os.path.join(self.get_datadir(datadir,"query"),
+ query_wsdl = "file:" + os.path.join(get_datadir(datadir,"query"),
"aviary-query.wsdl")
self.query_client_pool = ClientPool(query_wsdl, None)
@@ -648,23 +648,6 @@
self.type_to_aviary = self._type_to_aviary()
self.aviary_to_type = self._aviary_to_type()
- def get_datadir(self, datadir, subdir):
- if not type(datadir) in (tuple, list):
- datadir = [datadir]
-
- # Find the first element in datadir that is a valid
- # path. If the path has a subdirectory called
- # "subdir", consider that part of the path.
- for d in datadir:
- if os.path.isdir(d):
- s = os.path.join(d, subdir)
- if os.path.isdir(s):
- return s
- return d
- # Hmm, well, just return the first one since we're
- # going to get an error anyway.
- return datadir[0]
-
@classmethod
def _type_to_aviary(cls):
# Need to be able to turn simple Python types into Aviary types for attributes
Modified: trunk/sage/python/sage/util.py
===================================================================
--- trunk/sage/python/sage/util.py 2012-10-08 15:56:13 UTC (rev 5497)
+++ trunk/sage/python/sage/util.py 2012-10-08 20:27:48 UTC (rev 5498)
@@ -3,6 +3,7 @@
import re
import copy
import string
+import os
class MethodResult(object):
'''
@@ -306,3 +307,22 @@
else:
mechs = "ANONYMOUS"
return mechs
+
+def get_datadir(datadir, subdir):
+
+ if not type(datadir) in (tuple, list):
+ datadir = [datadir]
+
+ # Find the first element in datadir that is a valid
+ # path. If the path has a subdirectory called
+ # "subdir", consider that part of the path.
+ for d in datadir:
+ if os.path.isdir(d):
+ s = os.path.join(d, subdir)
+ if os.path.isdir(s):
+ return s
+ return d
+
+ # Hmm, well, just return the first one since we're
+ # going to get an error anyway.
+ return datadir[0]
11 years, 7 months
r5497 - in trunk: cumin/python/cumin wooly/python/wooly
by croberts@fedoraproject.org
Author: croberts
Date: 2012-10-08 15:56:13 +0000 (Mon, 08 Oct 2012)
New Revision: 5497
Modified:
trunk/cumin/python/cumin/objectselector.py
trunk/wooly/python/wooly/util.py
Log:
New method of date parsing. If the python-dateutil package is present, we use its parse method which is preferable. Otherwise, we try a series of formats that we define, which should catch all intuitive entries, but is not as complete as the dateutil package.
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2012-10-08 13:15:37 UTC (rev 5496)
+++ trunk/cumin/python/cumin/objectselector.py 2012-10-08 15:56:13 UTC (rev 5497)
@@ -6,7 +6,7 @@
from rosemary.model import RosemaryClass, RosemaryAttribute, RosemaryReference
from rosemary.sqlfilter import SqlFilter, SqlLikeFilter, SqlValueFilter, SqlDateValueFilter
-from wooly.util import StringCatalog, Writer, escape_entity
+from wooly.util import StringCatalog, Writer, escape_entity, parse_date_from_string
from wooly.datatable import DataTable, DataTableColumn
from wooly import Attribute, Widget, SessionAttribute, Parameter
from wooly.forms import Form, StringInput, FoldingFieldSubmitForm, OptionInputSet
@@ -19,9 +19,7 @@
from wooly.template import WidgetTemplate
from wooly import Notice
from cumin.formats import fmt_bytes
-from dateutil import parser
-
strings = StringCatalog(__file__)
class ObjectTable(DataTable):
@@ -390,7 +388,7 @@
if sql_column.type.literal == "timestamp":
try:
- searchvalue = parser.parse(customvalue)
+ searchvalue = parse_date_from_string(customvalue)
except Exception, e:
self.error_in_query = True
session.add_unique_notice(Notice("Error parsing valid timestamp from '%s', search results not updated" % customvalue, preamble=""))
@@ -438,7 +436,7 @@
post = ""
if sql_column.type.literal == "timestamp":
- searchvalue = parser.parse(customvalue)
+ searchvalue = parse_date_from_string(customvalue)
self.adapter.query.add_filter(self.SelectableFieldDateValueFilter(sql_column, searchvalue, operator))
elif sql_column.type.literal == "int8" or sql_column.type.literal == "float8":
if sql_column.name in self.special_columns:
Modified: trunk/wooly/python/wooly/util.py
===================================================================
--- trunk/wooly/python/wooly/util.py 2012-10-08 13:15:37 UTC (rev 5496)
+++ trunk/wooly/python/wooly/util.py 2012-10-08 15:56:13 UTC (rev 5497)
@@ -6,6 +6,7 @@
import random
import sys
import time
+from datetime import datetime
import struct
from copy import copy
@@ -19,6 +20,13 @@
from parsley.collectionsex import *
+try:
+ from dateutil import parser
+ have_dateutil = True
+except:
+ have_dateutil = False
+
+
quote_entities = {'"': """,
"'": "'"}
@@ -153,3 +161,35 @@
def __repr__(self):
return "%s('%s')" % (self.__class__.__name__, self.path)
+def parse_date_from_string(time_string):
+ if have_dateutil:
+ return parser.parse(string)
+ else:
+ """Return (<datetime.datetime() instance>) for the given datetime string."""
+
+ formats = [
+ ("us_day", "MM-DD-YYYY", "%m-%d-%Y"),
+ ("us_day_hour", "MM-DD-YYYY HH", "%m-%d-%Y %H"),
+ ("us_day_hour_min", "MM-DD-YYYY HH:MM", "%m-%d-%Y %H:%M"),
+ ("us_day_hour_min_sec", "MM-DD-YYYY HH:MM:SS", "%m-%d-%Y %H:%M:%S"),
+ ("hour_min", "HH:MM", "%H:%M"),
+ ("yearfirstmonth", "YYYY-MM", "%Y-%m"),
+ ("yearfirstday", "YYYY-MM-DD", "%Y-%m-%d"),
+ ("yearfirsthour", "YYYY-MM-DD HH", "%Y-%m-%d %H"),
+ ("yearfirstminute", "YYYY-MM-DD HH:MM", "%Y-%m-%d %H:%M"),
+ ("yearfirstsecond", "YYYY-MM-DD HH:MM:SS", "%Y-%m-%d %H:%M:%S"),
+ ("year", "YYYY", "%Y"),
+ ]
+ for formatname, pattern, format in formats:
+ try:
+ t_tuple = time.strptime(time_string, format)
+ t = datetime(*t_tuple[:6])
+ except ValueError:
+ pass
+ else:
+ return t
+ else:
+ raise ValueError("Could not determine date from %r: does not "
+ "match any of the accepted patterns ('%s')"
+ % (time_str, "', '".join(s for s,p,f in formats)))
+ return ""
\ No newline at end of file
11 years, 7 months
r5496 - trunk/wooly/python/wooly
by croberts@fedoraproject.org
Author: croberts
Date: 2012-10-08 13:15:37 +0000 (Mon, 08 Oct 2012)
New Revision: 5496
Modified:
trunk/wooly/python/wooly/__init__.py
Log:
Forgot to check-in add_unique_notice...doing so now.
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-10-05 17:30:50 UTC (rev 5495)
+++ trunk/wooly/python/wooly/__init__.py 2012-10-08 13:15:37 UTC (rev 5496)
@@ -981,6 +981,18 @@
n.append(notice)
except:
pass
+
+ def add_unique_notice(self, notice):
+ try:
+ notifications = self.client_session.attributes["login_session"].notifications
+ for n in notifications:
+ if not n.dismissed and n.message == notice.message:
+ # this would be a duplicate message, we can bail out
+ return False
+ notifications.append(notice)
+ except:
+ pass
+ return True
def get_notifications(self):
try:
11 years, 7 months
r5495 - in trunk/cumin: bin etc
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-10-05 17:30:50 +0000 (Fri, 05 Oct 2012)
New Revision: 5495
Modified:
trunk/cumin/bin/cumin-checkpid
trunk/cumin/etc/sysvinit-cumin
Log:
Adjust timing used by initd and cumin-checkpid
Initd will wait 1 sec longer than the timeout for the cumin master so
that false reports of failure to stop become less likely.
BZ800065 (modified)
Modified: trunk/cumin/bin/cumin-checkpid
===================================================================
--- trunk/cumin/bin/cumin-checkpid 2012-10-05 13:46:41 UTC (rev 5494)
+++ trunk/cumin/bin/cumin-checkpid 2012-10-05 17:30:50 UTC (rev 5495)
@@ -10,6 +10,9 @@
from cumin.config import CuminMasterConfig
+# sleep interval in seconds
+slp = 0.1
+
def read_exit(p, then, timeout):
while True:
try:
@@ -20,7 +23,7 @@
return 0
if datetime.now() - then > timedelta(seconds=timeout):
return -1
- sleep(0.25)
+ sleep(slp)
except:
return -1
@@ -33,7 +36,7 @@
return int(v[:-1])
if datetime.now() - then > timedelta(seconds=timeout):
return None
- sleep(0.25)
+ sleep(slp)
except:
return None
@@ -56,7 +59,7 @@
# When called from service this should be immediate
then = datetime.now()
while not os.path.isfile("/var/run/cumin.pid"):
- sleep(0.25)
+ sleep(slp)
if datetime.now() - then > timedelta(seconds=options.timeout):
return -1
@@ -72,7 +75,7 @@
config = CuminMasterConfig()
p = config.get_init_status_path()
while not os.path.isfile(p):
- sleep(0.25)
+ sleep(slp)
if datetime.now() - then > timedelta(seconds=options.timeout):
return -1
Modified: trunk/cumin/etc/sysvinit-cumin
===================================================================
--- trunk/cumin/etc/sysvinit-cumin 2012-10-05 13:46:41 UTC (rev 5494)
+++ trunk/cumin/etc/sysvinit-cumin 2012-10-05 17:30:50 UTC (rev 5495)
@@ -21,6 +21,7 @@
RETVAL=0
DELAY=5
+DELAY_PLUS=$(($DELAY+1))
start() {
@@ -88,7 +89,7 @@
RETVAL=$?
[ $RETVAL = 0 ] && touch $lockfile
if [ $RETVAL = 0 ]; then
- /usr/sbin/cumin-checkpid --timeout=$DELAY
+ /usr/sbin/cumin-checkpid --timeout=$DELAY_PLUS
RETVAL=$?
fi
@@ -96,7 +97,7 @@
if [ $RETVAL -ne 0 ] ; then
# We want to remove the pidfile when the
# cumin master indicates exit
- /usr/sbin/cumin-checkpid --exit --timeout=$DELAY
+ /usr/sbin/cumin-checkpid --exit --timeout=$DELAY_PLUS
if [ $? = 0 ]; then
rm -f $lockfile
rm -f $pidfile
@@ -119,7 +120,7 @@
echo
if [ $RETVAL -eq 0 ]; then
if [ $running -eq 0 ]; then
- /usr/sbin/cumin-checkpid --exit --timeout=$DELAY
+ /usr/sbin/cumin-checkpid --exit --timeout=$DELAY_PLUS
if [ $? -eq 0 ]; then
rm -f $lockfile
rm -f $pidfile
11 years, 7 months
r5494 - in trunk: cumin/python/cumin/account wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-10-05 13:46:41 +0000 (Fri, 05 Oct 2012)
New Revision: 5494
Modified:
trunk/cumin/python/cumin/account/widgets.py
trunk/cumin/python/cumin/account/widgets.strings
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/server.py
Log:
Improve CSRF handling with redirect instead of exception trace
BZ850759
Modified: trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- trunk/cumin/python/cumin/account/widgets.py 2012-10-04 19:57:06 UTC (rev 5493)
+++ trunk/cumin/python/cumin/account/widgets.py 2012-10-05 13:46:41 UTC (rev 5494)
@@ -73,8 +73,8 @@
self.origin = self.Origin(app, "origin")
self.add_parameter(self.origin)
- form = LoginForm(app, "form")
- self.add_child(form)
+ self.login_form = LoginForm(app, "form")
+ self.add_child(self.login_form)
# Make sure that we don't force a user to
# be logged in when visiting the login page!
@@ -101,8 +101,8 @@
def __init__(self, app, name):
super(LoginForm, self).__init__(app, name)
- self.login_invalid = Attribute(app, "login_invalid")
- self.add_attribute(self.login_invalid)
+ self.login_invalid = Parameter(app, "login_invalid")
+ self.add_parameter(self.login_invalid)
self.user_name = StringInput(app, "user_name")
self.user_name.size = 20
@@ -173,6 +173,8 @@
return self.get_string("roles_invalid")
elif reason == "credentials":
return self.get_string("login_invalid")
+ elif reason == "form":
+ return self.get_string("form_invalid")
class Submit(FormButton):
def render_content(self, session):
Modified: trunk/cumin/python/cumin/account/widgets.strings
===================================================================
--- trunk/cumin/python/cumin/account/widgets.strings 2012-10-04 19:57:06 UTC (rev 5493)
+++ trunk/cumin/python/cumin/account/widgets.strings 2012-10-05 13:46:41 UTC (rev 5494)
@@ -81,3 +81,6 @@
<p class="login_invalid">There are no valid roles
configured for this account.</p>
+[LoginForm.form_invalid]
+<p class="login_invalid">The form expired and cannot
+be validated. Please log in again.</p>
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-10-04 19:57:06 UTC (rev 5493)
+++ trunk/wooly/python/wooly/__init__.py 2012-10-05 13:46:41 UTC (rev 5494)
@@ -767,10 +767,38 @@
self.csrf_value = None
self.post = False
- def check_csrf(self):
- if self.client_session.get_csrf() != self.csrf_value:
- log.info("Possible CSRF attempt using %s" % self)
- raise CSRFException("Possible CSRF attempt")
+ def login_current(self):
+ login = self.client_session.attributes.get("login_session")
+ if login:
+ when = datetime.now() - timedelta(hours=24)
+ if login.created > when:
+ return True
+ return False
+
+ def check_csrf(self, page):
+ if self.client_session.get_csrf() != self.csrf_value:
+ mainpage = None
+ if self.login_current():
+ log.info("Possible CSRF attempt using %s" % self)
+
+ if self.app.authorizator.is_enforcing():
+ try:
+ p = self.app.authorizator.find_mainpage(self)
+ mainpage = self.app.pages_by_name[p]
+ except:
+ pass
+ if mainpage is None:
+ mainpage = self.app.pages_by_name["index.html"]
+ sess = Session(mainpage)
+
+ # If we are redirecting from a stale login form
+ # to the login form, add the extra notice so
+ # users understand why they have to log in again
+ if page == self.app.login_page and mainpage == self.app.login_page:
+ self.app.login_page.login_form.login_invalid.set(sess, "form")
+
+ page.redirect.set(self, sess.marshal())
+ raise PageRedirect()
def branch(self):
session = Session(self.page)
Modified: trunk/wooly/python/wooly/server.py
===================================================================
--- trunk/wooly/python/wooly/server.py 2012-10-04 19:57:06 UTC (rev 5493)
+++ trunk/wooly/python/wooly/server.py 2012-10-05 13:46:41 UTC (rev 5494)
@@ -122,7 +122,7 @@
or last_modified > last_requested:
try:
if session.post:
- session.check_csrf()
+ session.check_csrf(page)
content = page.service(session)
status = "200 OK"
except PageRedirect:
11 years, 7 months
r5493 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-10-04 19:57:06 +0000 (Thu, 04 Oct 2012)
New Revision: 5493
Modified:
trunk/cumin/python/cumin/objectselector.py
trunk/cumin/python/cumin/objectselector.strings
trunk/cumin/python/cumin/util.py
Log:
Tweaks for the object selection column searching. Now trying to do the right thing for date columns as well as the MonitorSelfAge columns which require some tweaking of the user input to match what is actually stored in postgres.
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2012-10-02 18:19:35 UTC (rev 5492)
+++ trunk/cumin/python/cumin/objectselector.py 2012-10-04 19:57:06 UTC (rev 5493)
@@ -1,7 +1,7 @@
from cumin.objectframe import ObjectFrame
from cumin.qmfadapter import ObjectQmfAdapter, ObjectQmfField
from cumin.sqladapter import ObjectSqlAdapter, ObjectSqlField
-from cumin.util import Identifiable, xml_escape
+from cumin.util import Identifiable, xml_escape, fmt_ddhhmm_timestamp
from rosemary.model import RosemaryClass, RosemaryAttribute, RosemaryReference
from rosemary.sqlfilter import SqlFilter, SqlLikeFilter, SqlValueFilter, SqlDateValueFilter
@@ -17,7 +17,9 @@
from wooly.widgets import WidgetSet, ItemSet
import wooly
from wooly.template import WidgetTemplate
+from wooly import Notice
from cumin.formats import fmt_bytes
+from dateutil import parser
strings = StringCatalog(__file__)
@@ -368,22 +370,63 @@
class SelectableSearchObjectTable(ObjectTable):
def __init__(self, app, name, cls):
super(SelectableSearchObjectTable, self).__init__(app, name, cls)
+ self.error_in_query = False
+ self.special_columns = ["MonitorSelfAge"]
- ## think about a do_process that will set up values from the URL maybe??
+ def do_process(self, session):
+ #here we are making sure that if you are searching an int or a timestamp column
+ #that your value can be parsed as such.
+
+ customfield = self.parent.select_input.get(session)
+ customvalue = self.parent.selectablefilters.children_by_name['search'].get(session)
+ self.error_in_query = False
+
+ if customfield is None or customvalue is None or customvalue == "":
+ return
+ try:
+ sql_column = self.cls._properties_by_name[customfield].sql_column
+ except:
+ sql_column = self.cls._statistics_by_name[customfield].sql_column
+
+ if sql_column.type.literal == "timestamp":
+ try:
+ searchvalue = parser.parse(customvalue)
+ except Exception, e:
+ self.error_in_query = True
+ session.add_unique_notice(Notice("Error parsing valid timestamp from '%s', search results not updated" % customvalue, preamble=""))
+ if sql_column.type.literal == "int8":
+ if sql_column.name in self.special_columns:
+ try:
+ searchvalue = fmt_ddhhmm_timestamp(customvalue)
+ except:
+ self.error_in_query = True
+ session.add_unique_notice(Notice("Error parsing valid dd:hh:mm from '%s', search results not updated" % customvalue, preamble=""))
+ else:
+ try:
+ int(customvalue)
+ except:
+ self.error_in_query = True
+ session.add_unique_notice(Notice("Error parsing valid integer from '%s', search results not updated" % customvalue, preamble=""))
+
+
def get_data_values(self, session):
values = dict()
-
+
customfield = self.parent.select_input.get(session)
customvalue = self.parent.selectablefilters.children_by_name['search'].get(session)
- operator = self.parent.select_input.operator_param.get(session)
-
+ operator = str(self.parent.select_input.operator_param.get(session))
+
#we need to factor-in filter_specs that may have been placed on the table
for this, that, fobj in self.parent.table.filter_specs:
obj = fobj.get(session)
values[this.name] = getattr(obj, that.name)
-
+
#since these are added at runtime, we need to clear out the old ones each time around
- self.adapter.query.filters = [filter for filter in self.adapter.query.filters if not isinstance(filter, self.SelectableFieldFilter)]
+ self.adapter.query.filters = [filter for filter in self.adapter.query.filters if not isinstance(filter, self.SelectableFieldFilter)]
+
+ if self.error_in_query:
+ return values
+
if customfield is None or customvalue is None or customvalue == "":
return values
try:
@@ -394,19 +437,23 @@
pre = ""
post = ""
- if sql_column.type.literal == "timestamp":
- self.adapter.query.add_filter(self.SelectableFieldDateValueFilter(sql_column, customvalue))
+ if sql_column.type.literal == "timestamp":
+ searchvalue = parser.parse(customvalue)
+ self.adapter.query.add_filter(self.SelectableFieldDateValueFilter(sql_column, searchvalue, operator))
elif sql_column.type.literal == "int8" or sql_column.type.literal == "float8":
- if operator == ">=":
- self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, ">="))
- elif operator == ">":
- self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, ">"))
- elif operator == "<=":
- self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, "<="))
- elif operator == "<":
- self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, "<"))
- else:
- self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column))
+ if sql_column.name in self.special_columns:
+ customvalue = str(fmt_ddhhmm_timestamp(customvalue))
+ if sql_column.type.literal == "int8":
+ if operator == ">=":
+ self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, ">="))
+ elif operator == ">":
+ self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, ">"))
+ elif operator == "<=":
+ self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, "<="))
+ elif operator == "<":
+ self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, "<"))
+ else:
+ self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column))
else:
post = "%"
self.adapter.query.add_filter(self.SelectableFieldLikeFilter(sql_column))
@@ -414,7 +461,8 @@
if not "%" in customvalue:
pre = type == SqlLikeFilter.CONTAINS and "%%" or ""
else:
- post = ""
+ post = ""
+
values[customfield] = "%s%s%s" % (pre, customvalue, post)
return values
Modified: trunk/cumin/python/cumin/objectselector.strings
===================================================================
--- trunk/cumin/python/cumin/objectselector.strings 2012-10-02 18:19:35 UTC (rev 5492)
+++ trunk/cumin/python/cumin/objectselector.strings 2012-10-04 19:57:06 UTC (rev 5493)
@@ -312,7 +312,7 @@
select_width = select_box.getWidth();
adjust_pixels_noops = 27 + select_width;
adjust_pixels_ops = 72 + select_width;
- if (field_type != "int8" && field_type != "float8") {
+ if (field_type != "int8" && field_type != "float8" && field_type != "timestamp") {
select_box.getNext().setAttribute("style", "display:none");
select_box.getParent().getElement("label").setStyle("left", adjust_pixels_noops + "px")
} else {
Modified: trunk/cumin/python/cumin/util.py
===================================================================
--- trunk/cumin/python/cumin/util.py 2012-10-02 18:19:35 UTC (rev 5492)
+++ trunk/cumin/python/cumin/util.py 2012-10-04 19:57:06 UTC (rev 5493)
@@ -290,3 +290,24 @@
self.routine()
except:
pass
+
+def fmt_ddhhmm_timestamp(ddhhmm_string):
+ """Takes a duration in dd:hh:mm format, converts to seconds"""
+
+ dd_hh_mm = ddhhmm_string.split(":")
+ dd = hh = mm = 0
+ try:
+ dd = int(dd_hh_mm[0])
+ hh = int(dd_hh_mm[1])
+ mm = int(dd_hh_mm[2])
+ except Exception, e:
+ if isinstance(e, ValueError):
+ raise e
+ else:
+ # If no hh or mm are present, that's ok
+ pass
+
+ days = dd * 86400
+ hours = hh * 3600
+ minutes = mm * 60
+ return days + hours + minutes
\ No newline at end of file
11 years, 7 months
r5492 - trunk/cumin/bin
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-10-02 18:19:35 +0000 (Tue, 02 Oct 2012)
New Revision: 5492
Modified:
trunk/cumin/bin/cumin-database
Log:
Adjustments to postgres user creation.
If a dev user is created, prompt for creation of the cumin postgres user
to support cases where cumin will be run as a dev instance and also a
service on the same machine.
Give a default for prompts and allow ENTER to select default.
Modified: trunk/cumin/bin/cumin-database
===================================================================
--- trunk/cumin/bin/cumin-database 2012-10-02 14:07:46 UTC (rev 5491)
+++ trunk/cumin/bin/cumin-database 2012-10-02 18:19:35 UTC (rev 5492)
@@ -189,19 +189,44 @@
NOTICE: This appears to be a development instance owned by $dev_postgres_user
-To run Cumin as this user you *MUST* add a matching postgres user.
-Enter 'yes' to add the $dev_postgres_user user now:
+If Cumin will be run as this user, then this user should be the owner of the
+database (when Cumin is installed as a package, the 'cumin' user is the owner).
+
+Create the $dev_postgres_user postgres user and make it the database owner [yes]|no:
EOF
read add_dev_user
+ if [ -z "$add_dev_user" ]; then
+ add_dev_user=yes
+ fi
if [[ $add_dev_user == "yes" ]]; then
- run "createuser --superuser ${dev_postgres_user}" postgres
+ run "createuser --no-superuser --no-createdb --no-createrole ${dev_postgres_user}" postgres
else
- echo No additional postgres user created
+ echo No ${dev_postgres_user} postgres user created
fi
fi
}
+function add-cumin-user {
+ cat <<EOF
+
+If Cumin will *ALSO* be installed as a package and run as a service on this machine,
+a ${dbname} postgres superuser must be created for use by the service instance.
+
+Create the ${dbname} postgres superuser [no]|yes:
+EOF
+
+ read add_cumin_user
+ if [ -z "$add_cumin_user" ]; then
+ add_cumin_user=no
+ fi
+ if [[ $add_cumin_user == "yes" ]]; then
+ run "createuser --superuser ${dbname}" postgres
+ else
+ echo No ${dbname} postgres user created
+ fi
+}
+
function install {
check-environment || exit 1
@@ -286,12 +311,26 @@
exit 1
fi
- run "createuser --superuser ${dbname}" postgres
+ # If we add a devel user, we should have a cumin
+ # superuser iff cumin will be run as a package.
+ # If it will not be run as a package, we can skip it.
+ # Ask the user (note, it has to be a superuser because
+ # we can only have 1 owner of a database....)
if [[ $CUMIN_DEVEL_INSTANCE ]]; then
add-postgres-user
+ if [[ $add_dev_user == 'yes' ]]; then
+ # ask about a cumin user...
+ add-cumin-user
+ run "createdb --owner=${dev_postgres_user} ${dbname}" postgres
+ fi
fi
- run "createdb --owner=${dbname} ${dbname}" postgres
+ # If we didn't create a devel user, just proceed as normal
+ if [[ $add_dev_user != 'yes' ]]; then
+ run "createuser --no-superuser --no-createdb --no-createrole ${dbname}" postgres
+ run "createdb --owner=${dbname} ${dbname}" postgres
+ fi
+
# If we are a dev instance we have to be careful
# when we delegate to cumin-admin to create the
# schema
11 years, 7 months
r5491 - trunk/cumin/model/upgrades
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-10-02 14:07:46 +0000 (Tue, 02 Oct 2012)
New Revision: 5491
Modified:
trunk/cumin/model/upgrades/1.1a_to_1.2
Log:
Correct error in upgrade script
Modified: trunk/cumin/model/upgrades/1.1a_to_1.2
===================================================================
--- trunk/cumin/model/upgrades/1.1a_to_1.2 2012-10-01 15:45:32 UTC (rev 5490)
+++ trunk/cumin/model/upgrades/1.1a_to_1.2 2012-10-02 14:07:46 UTC (rev 5491)
@@ -1,5 +1,5 @@
#!/bin/bash
-su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission\" add column \"Suspended\" bigint'
-su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission_samples\" add column \"Suspended\" bigint'
-su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission\" add column \"TransferringOutput\" bigint'
-su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission_samples\" add column \"TransferringOutput\" bigint'
+su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission\" add column \"Suspended\" bigint | psql -d cumin'
+su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission_samples\" add column \"Suspended\" bigint | psql -d cumin'
+su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission\" add column \"TransferringOutput\" bigint | psql -d cumin'
+su - postgres -c 'echo alter table \"com.redhat.grid\".\"Submission_samples\" add column \"TransferringOutput\" bigint | psql -d cumin'
11 years, 7 months