r5573 - in branches/elephant/cumin: bin python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-12-10 20:53:37 +0000 (Mon, 10 Dec 2012)
New Revision: 5573
Modified:
branches/elephant/cumin/bin/cumin-web
branches/elephant/cumin/python/cumin/config.py
branches/elephant/cumin/python/cumin/kerbauth.py
Log:
Bringing a few changes from trunk over to prevent startup login errors.
Modified: branches/elephant/cumin/bin/cumin-web
===================================================================
--- branches/elephant/cumin/bin/cumin-web 2012-12-10 19:46:56 UTC (rev 5572)
+++ branches/elephant/cumin/bin/cumin-web 2012-12-10 20:53:37 UTC (rev 5573)
@@ -71,7 +71,6 @@
cumin.ldap_tls_cacertfile = values.ldap_tls_cacertfile
def set_kerberos_configs(cumin, values):
- cumin.kerberos_server = values.kerberos_server
cumin.kerberos_realm = values.kerberos_realm
def check_cert_files(opts):
Modified: branches/elephant/cumin/python/cumin/config.py
===================================================================
--- branches/elephant/cumin/python/cumin/config.py 2012-12-10 19:46:56 UTC (rev 5572)
+++ branches/elephant/cumin/python/cumin/config.py 2012-12-10 20:53:37 UTC (rev 5573)
@@ -141,10 +141,7 @@
param = ConfigParameter(self, "ldap_timeout", int)
param.default = 30
-
- param = ConfigParameter(self, "kerberos_server", str)
- param.default = ""
-
+
param = ConfigParameter(self, "kerberos_realm", str)
param.default = ""
Modified: branches/elephant/cumin/python/cumin/kerbauth.py
===================================================================
--- branches/elephant/cumin/python/cumin/kerbauth.py 2012-12-10 19:46:56 UTC (rev 5572)
+++ branches/elephant/cumin/python/cumin/kerbauth.py 2012-12-10 20:53:37 UTC (rev 5573)
@@ -11,10 +11,8 @@
class CuminAuthenticatorKerberos(object):
def __init__(self, mech, app):
log.info("Initializing %s", self)
- self.kerb_url = app.kerberos_server
self.kerb_realm = app.kerberos_realm
- if (self.kerb_url is not None and self.kerb_realm is not None
- and self.kerb_url is not "" and self.kerb_realm is not ""):
+ if (self.kerb_realm is not None and self.kerb_realm is not ""):
self.valid = True
else:
self.valid = False
@@ -25,7 +23,7 @@
isAuth = False
if self.valid:
try:
- isAuth = kerberos.checkPassword(username, password, self.kerb_url, self.kerb_realm)
+ isAuth = kerberos.checkPassword(username, password, "HTTP", self.kerb_realm)
except Exception, e:
log.debug("Auth failed %s" % e)
else:
@@ -34,4 +32,7 @@
@staticmethod
def isKerbAvail():
- return have_kerberos
\ No newline at end of file
+ return have_kerberos
+
+ def find_user(self, user):
+ pass
\ No newline at end of file
11 years, 4 months
r5572 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-12-10 19:46:56 +0000 (Mon, 10 Dec 2012)
New Revision: 5572
Modified:
trunk/cumin/python/cumin/objectselector.py
Log:
BZ 879314: Adding special query logic to support searching on "image size" fields that come with a unit. Searches should not include the unit. Only numeric input is supported.
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2012-12-10 17:42:33 UTC (rev 5571)
+++ trunk/cumin/python/cumin/objectselector.py 2012-12-10 19:46:56 UTC (rev 5572)
@@ -4,7 +4,7 @@
from cumin.util import Identifiable, xml_escape, fmt_ddhhmm_timestamp
from rosemary.model import RosemaryClass, RosemaryAttribute, RosemaryReference
-from rosemary.sqlfilter import SqlFilter, SqlLikeFilter, SqlILikeFilter, SqlValueFilter, SqlDateValueFilter
+from rosemary.sqlfilter import SqlFilter, SqlLikeFilter, SqlILikeFilter, SqlValueFilter, SqlDateValueFilter, SqlComparisonFilter
from wooly.util import StringCatalog, Writer, escape_entity, parse_date_from_string
from wooly.datatable import DataTable, DataTableColumn
@@ -370,6 +370,7 @@
super(SelectableSearchObjectTable, self).__init__(app, name, cls)
self.error_in_query = False
self.special_columns = ["MonitorSelfAge"]
+ self.unitSizeFields = ["MonitorSelfImageSize"]
def do_process(self, session):
#here we are making sure that if you are searching an int or a timestamp column
@@ -441,7 +442,10 @@
pre = ""
post = ""
- if sql_column.type.literal == "timestamp":
+ if sql_column.name in self.unitSizeFields:
+ customvalue = int(customvalue)
+ self.adapter.query.add_filter(self.SelectableFieldSizeValueFilter(sql_column, operator))
+ elif sql_column.type.literal == "timestamp":
searchvalue = parse_date_from_string(customvalue)
self.adapter.query.add_filter(self.SelectableFieldDateEnqueuedValueFilter(sql_column, searchvalue, operator))
elif sql_column.type.literal == "int8" or sql_column.type.literal == "float8":
@@ -541,6 +545,10 @@
def emit(self):
return "round(cast(%s as numeric), 2) %s round(%s, 2)" % (self.this, self.operator, self.that)
+ class SelectableFieldSizeValueFilter(SqlValueFilter, SelectableFieldFilter):
+ def emit(self):
+ return "cast(%s as int) / 1024 %s %s" % (self.this, self.operator, self.that)
+
class SelectableFieldUptimeValueFilter(SqlValueFilter, SelectableFieldFilter):
#necessary because we only show day:hour:minute to the user, but we store seconds in
#the cumin database. This filter takes the value from the user, and
11 years, 4 months
r5571 - trunk/wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-12-10 17:42:33 +0000 (Mon, 10 Dec 2012)
New Revision: 5571
Modified:
trunk/wooly/python/wooly/table.py
Log:
Wrong method name in TableColumnCell (render_cell_title should be render_title)
BZ885729
Modified: trunk/wooly/python/wooly/table.py
===================================================================
--- trunk/wooly/python/wooly/table.py 2012-12-10 15:50:36 UTC (rev 5570)
+++ trunk/wooly/python/wooly/table.py 2012-12-10 17:42:33 UTC (rev 5571)
@@ -261,7 +261,7 @@
def render_content(self, session, record):
return self.parent.do_render_cell_content(session, record)
- def render_cell_title(self, session, record):
+ def render_title(self, session, record):
#gives us the title="" attribute for each table cell
return self.parent.do_render_cell_title(session, record)
@@ -304,10 +304,7 @@
class LinkColumnCell(TableColumnCell):
def render_href(self, session, record):
- return self.parent.render_cell_href(session, record)
-
- def render_title(self, session, record):
- return self.parent.render_cell_title(session, record)
+ return self.parent.render_cell_href(session, record)
class CheckboxColumnHeader(TableColumnHeader):
def render_name(self, session):
11 years, 4 months
r5570 - trunk/cumin/python/cumin
by croberts@fedoraproject.org
Author: croberts
Date: 2012-12-10 15:50:36 +0000 (Mon, 10 Dec 2012)
New Revision: 5570
Modified:
trunk/cumin/python/cumin/objectselector.py
Log:
BZ 879314: Fixing searches of floating point columns. Cumin displays values rounded to 2 decimal places. The searching now takes that into account by rounding the value entered to 2 decimal places as well.
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2012-12-07 22:08:00 UTC (rev 5569)
+++ trunk/cumin/python/cumin/objectselector.py 2012-12-10 15:50:36 UTC (rev 5570)
@@ -449,17 +449,10 @@
#adjust our search value to be an int based on the timestamp
customvalue = str(fmt_ddhhmm_timestamp(customvalue))
self.adapter.query.add_filter(self.SelectableFieldUptimeValueFilter(sql_column, operator))
- if (sql_column.type.literal == "int8" or sql_column.type.literal == "float8") and sql_column.name not in self.special_columns:
- 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.type.literal == "int8" and sql_column.name not in self.special_columns:
+ self.adapter.query.add_filter(self.SelectableFieldValueFilter(sql_column, operator))
+ if sql_column.type.literal == "float8" and sql_column.name not in self.special_columns:
+ self.adapter.query.add_filter(self.SelectableFieldRoundedFloatValueFilter(sql_column, operator))
else:
post = "%"
if not "%" in customvalue:
@@ -543,6 +536,10 @@
class SelectableFieldDateEnqueuedValueFilter(SqlDateValueFilter, SelectableFieldFilter):
def emit(self):
return "date_trunc('second', %s) %s date_trunc('second', timestamp '%s')" % (self.this, self.operator, self.that)
+
+ class SelectableFieldRoundedFloatValueFilter(SqlValueFilter, SelectableFieldFilter):
+ def emit(self):
+ return "round(cast(%s as numeric), 2) %s round(%s, 2)" % (self.this, self.operator, self.that)
class SelectableFieldUptimeValueFilter(SqlValueFilter, SelectableFieldFilter):
#necessary because we only show day:hour:minute to the user, but we store seconds in
11 years, 4 months
r5569 - in trunk: cumin/python/cumin wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-12-07 22:08:00 +0000 (Fri, 07 Dec 2012)
New Revision: 5569
Modified:
trunk/cumin/python/cumin/widgets.py
trunk/wooly/python/wooly/__init__.py
Log:
Move the login expiration delta to a single point in the code
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2012-12-07 21:32:38 UTC (rev 5568)
+++ trunk/cumin/python/cumin/widgets.py 2012-12-07 22:08:00 UTC (rev 5569)
@@ -1314,9 +1314,7 @@
login = session.client_session.attributes.get("login_session")
if login:
- when = datetime.now() - timedelta(hours=24)
- if login.created > when:
- return True
+ return session.login_current(login)
elif self.app.auth_proxy or self.app.user:
username = self.app.user
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-12-07 21:32:38 UTC (rev 5568)
+++ trunk/wooly/python/wooly/__init__.py 2012-12-07 22:08:00 UTC (rev 5569)
@@ -299,12 +299,7 @@
pass
def authorized(self, session):
- login = session.client_session.attributes.get("login_session")
- if login:
- when = datetime.now() - timedelta(hours=24)
- if login.created > when:
- return True
- return False
+ return session.login_current()
def redirect_to_login(self, session):
# Redirect to the login page when not logged in.
@@ -772,8 +767,9 @@
self.csrf_value = None
self.post = False
- def login_current(self):
- login = self.client_session.attributes.get("login_session")
+ def login_current(self, login=None):
+ if not login:
+ login = self.client_session.attributes.get("login_session")
if login:
when = datetime.now() - timedelta(hours=24)
if login.created > when:
11 years, 5 months
r5568 - trunk/wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-12-07 21:32:38 +0000 (Fri, 07 Dec 2012)
New Revision: 5568
Modified:
trunk/wooly/python/wooly/__init__.py
trunk/wooly/python/wooly/pages.py
trunk/wooly/python/wooly/server.py
Log:
When an update request is seen for a session with an expired login,
return a response with a Location header requesting a reload. This
will reload the mainpage and Cumin will take the user to the login page
on the way.
BZ873335
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-12-07 18:00:35 UTC (rev 5567)
+++ trunk/wooly/python/wooly/__init__.py 2012-12-07 21:32:38 UTC (rev 5568)
@@ -306,13 +306,18 @@
return True
return False
+ def redirect_to_login(self, session):
+ # Redirect to the login page when not logged in.
+ # For some page types (like Update pages) this
+ # is accomplished differently so allow an overload...
+ page = self.app.login_page
+ sess = Session(page)
+ page.origin.set(sess, session.marshal())
+ self.redirect.set(session, sess.marshal())
+
def process(self, session, *args):
if self.check_login and not self.authorized(session):
- # redirect to the login page
- page = self.app.login_page
- sess = Session(page)
- page.origin.set(sess, session.marshal())
- self.redirect.set(session, sess.marshal())
+ self.redirect_to_login(session)
return
if not self.app.authorize_cb(session, self):
Modified: trunk/wooly/python/wooly/pages.py
===================================================================
--- trunk/wooly/python/wooly/pages.py 2012-12-07 18:00:35 UTC (rev 5567)
+++ trunk/wooly/python/wooly/pages.py 2012-12-07 21:32:38 UTC (rev 5568)
@@ -264,6 +264,14 @@
if redirect:
self.redirect.set(session, redirect)
+ def redirect_to_login(self, session):
+ # In the case of an update request when not logged in,
+ # we just want to force a failed update with a Location
+ # header that specifies a reload. This will cause the
+ # client browser to reload the page and Cumin will
+ # redirect to login from there with the correct origin.
+ raise UpdateRedirect("reload")
+
def service(self, session):
self.process(session)
Modified: trunk/wooly/python/wooly/server.py
===================================================================
--- trunk/wooly/python/wooly/server.py 2012-12-07 18:00:35 UTC (rev 5567)
+++ trunk/wooly/python/wooly/server.py 2012-12-07 21:32:38 UTC (rev 5568)
@@ -156,8 +156,11 @@
# process a location change. Javascript code in the
# update handler will look for the header.
status = "200 OK"
- headers.append(("Location",
- page.validate_redirect(session, e.url, env)))
+ if e.url == "reload":
+ headers.append(("Location", "reload"))
+ else:
+ headers.append(("Location",
+ page.validate_redirect(session, e.url, env)))
except:
url = page.redirect_on_exception(session)
if url:
11 years, 5 months
r5567 - trunk/mint/python/mint/plumage
by croberts@fedoraproject.org
Author: croberts
Date: 2012-12-07 18:00:35 +0000 (Fri, 07 Dec 2012)
New Revision: 5567
Modified:
trunk/mint/python/mint/plumage/session.py
Log:
BZ 883784: Addressing this by eliminating the map_reduce logic that tallied cpu/memory in favor of just looping through the cursor for each type of slot (used, unused, etc) at each time period. This approach seems less flaky and should still yield proper results.
Modified: trunk/mint/python/mint/plumage/session.py
===================================================================
--- trunk/mint/python/mint/plumage/session.py 2012-12-06 21:18:00 UTC (rev 5566)
+++ trunk/mint/python/mint/plumage/session.py 2012-12-07 18:00:35 UTC (rev 5567)
@@ -7,7 +7,6 @@
from update import ObjectUpdate
from random import randrange
from datetime import timedelta, datetime
-from bson.code import Code
try:
from pymongo import Connection
@@ -24,28 +23,19 @@
UTC_DIFF = datetime.utcnow() - datetime.now() # needed because everything in mongo is UTC
-timestamp_mapper = Code("""
- function () {
- emit({ts:this.ts, st:this.st}, {mem: this.mem, cpu: this.cpu});
- }
- """)
-timestamp_reducer = Code("""
- function (key, values) {
- var memsum = 0;
- var cpusum = 0;
- values.forEach(function(doc) {
- memsum += doc.mem;
- cpusum += doc.cpu;
- });
- return {mem: memsum, cpu: cpusum}; //format of this needs to be same as second param of emit
- }
- """)
-
-
class RecordObject(object):
- pass
+ def __str__(self):
+ sb = []
+ for key in self.__dict__:
+ sb.append("{key}='{value}'".format(key=key, value=self.__dict__[key]))
+
+ return ', '.join(sb)
+
+ def __repr__(self):
+ return self.__str__()
+
class PlumageSession(object):
def __init__(self, app, server_host, server_port):
self.app = app
@@ -302,43 +292,47 @@
class PlumageOSUtilSessionThread(PlumageSessionThread):
def fillOSUtilStats(self, time, temptable):
record = RecordObject()
+
+ totalrecs = self.collection.find({'ts':time})
+ usedrecs = self.collection.find({'ts':time,'st':{'$nin':['Unclaimed','Owner']}})
+ unusedrecs = self.collection.find({'ts':time,'st':'Unclaimed'})
+ ownerrecs = self.collection.find({'ts':time,'st':'Owner'})
+ matchedrecs = self.collection.find({'ts':time,'st':'Matched'})
+
record.host= "%s:%s" % (self.connection.host, self.connection.port)
- record.total = len(self.collection.find({'ts':time}).distinct('n'))
- record.used = len(self.collection.find({'ts':time,'st':{'$nin':['Unclaimed','Owner']}}).distinct('n'))
- record.unused = len(self.collection.find({'ts':time,'st':'Unclaimed'}).distinct('n'))
- record.owner = len(self.collection.find({'ts':time,'st':'Owner'}).distinct('n'))
- reduced = self.collection.map_reduce(timestamp_mapper, timestamp_reducer, temptable, query={'ts':time,})
- reduced_collection = Collection(self.database,temptable)
+ record.total = len(totalrecs.distinct('n'))
+ record.used = len(usedrecs.distinct('n'))
+ record.unused = len(unusedrecs.distinct('n'))
+ record.owner = len(ownerrecs.distinct('n'))
- result_claimed = reduced_collection.find({'_id.st':'Claimed'})
- result_unclaimed = reduced_collection.find({'_id.st':'Unclaimed'})
- result_owner = reduced_collection.find({'_id.st':'Owner'})
- result_matched = reduced_collection.find({'_id.st':'Matched'})
-
- record.freemem = self.getStat(result_unclaimed, 'mem')
- record.freecpu = self.getStat(result_unclaimed, 'cpu')
- record.usedmem = self.getStat(result_claimed, 'mem')
- record.usedcpu = self.getStat(result_claimed, 'cpu')
- record.availmem = self.getStat(result_claimed, 'mem') + self.getStat(result_unclaimed, 'mem')
- record.availcpu = self.getStat(result_claimed, 'cpu') + self.getStat(result_unclaimed, 'cpu')
- record.totalmem = self.getStat(result_claimed, 'mem') + self.getStat(result_unclaimed, 'mem') + self.getStat(result_owner, 'mem') + self.getStat(result_matched, 'mem')
- record.totalcpu = self.getStat(result_claimed, 'cpu') + self.getStat(result_unclaimed, 'cpu') + self.getStat(result_owner, 'cpu') + self.getStat(result_matched, 'cpu')
+ record.freemem = self.getStat(unusedrecs, 'mem')
+ record.freecpu = self.getStat(unusedrecs, 'cpu')
+ record.usedmem = self.getStat(usedrecs, 'mem')
+ record.usedcpu = self.getStat(usedrecs, 'cpu')
+ record.availmem = self.getStat(usedrecs, 'mem') + self.getStat(unusedrecs, 'mem')
+ record.availcpu = self.getStat(usedrecs, 'cpu') + self.getStat(unusedrecs, 'cpu')
+ record.totalmem = self.getStat(usedrecs, 'mem') + self.getStat(unusedrecs, 'mem') + self.getStat(ownerrecs, 'mem') + self.getStat(matchedrecs, 'mem')
+ record.totalcpu = self.getStat(usedrecs, 'cpu') + self.getStat(unusedrecs, 'cpu') + self.getStat(ownerrecs, 'cpu') + self.getStat(matchedrecs, 'cpu')
if(record.total != record.owner):
record.efficiency = (record.used/(record.total-record.owner))*100
else:
record.efficiency = 0
record.ts = time - UTC_DIFF
+
+ log.debug("For time [%s] Adding OSUtil record of [%s]" % (time,record))
return record
- def getStat(self, result_object, item):
- itemcount = 0
- try:
- itemcount = result_object[0]['value'][item]
- except:
- return 0
- return itemcount
-
+ def getStat(self, recordset, stat):
+ recordset.rewind() # be sure that we're working with a fresh cursor
+ total = 0
+ for rec in recordset:
+ try:
+ total += rec[stat]
+ except:
+ pass
+ return total
+
def run(self):
while True:
self._check_connection()
11 years, 5 months
r5566 - trunk/wooly/python/wooly
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-12-06 21:18:00 +0000 (Thu, 06 Dec 2012)
New Revision: 5566
Modified:
trunk/wooly/python/wooly/__init__.py
Log:
Tweak for redirect from stale login page. Explanatory note is now displayed.
BZ850759
Modified: trunk/wooly/python/wooly/__init__.py
===================================================================
--- trunk/wooly/python/wooly/__init__.py 2012-12-06 15:03:59 UTC (rev 5565)
+++ trunk/wooly/python/wooly/__init__.py 2012-12-06 21:18:00 UTC (rev 5566)
@@ -777,26 +777,34 @@
def check_csrf(self, page):
if self.client_session.get_csrf() != self.csrf_value:
- mainpage = None
+ # For a current login, log that there may have been
+ # a possible CSRF attempt. If the client is not
+ # logged in then this is probably due to a stale login
+ # form instead.
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")
-
+ # If we are currently on the login page,redirect
+ # back to the login page instead of the mainpage
+ # with a notice explaining the need to login in again.
+ # If we go to the mainpage we will lose the warning
+ # because the 'login_invalid' parameter is only a page
+ # parameter for the login_page and will not be rendered
+ # in the url for other pages.
+ if page == self.app.login_page:
+ sess = Session(page)
+ page.login_form.login_invalid.set(sess, "form")
+ else:
+ mainpage = None
+ 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)
page.redirect.set(self, sess.marshal())
raise PageRedirect()
@@ -1017,8 +1025,15 @@
self.timestamp = datetime.now() #may want a superclass since this is duplicated in TaskInvocation
def get_message(self, session):
- timestamp = "%s-%02d-%02d %02d:%02d:%02d" % (self.timestamp.year, self.timestamp.month, self.timestamp.day, self.timestamp.hour, self.timestamp.minute, self.timestamp.second)
- return "<span class='notification_time'>%s</span> %s: %s" % (timestamp, self.preamble, self.message)
+ timestamp = "%s-%02d-%02d %02d:%02d:%02d" % (self.timestamp.year,
+ self.timestamp.month,
+ self.timestamp.day,
+ self.timestamp.hour,
+ self.timestamp.minute,
+ self.timestamp.second)
+ return "<span class='notification_time'>%s</span> %s: %s" % (timestamp,
+ self.preamble,
+ self.message)
class SessionAttribute(object):
def __init__(self, widget, name):
11 years, 5 months
r5565 - trunk/wooly/python/wooly
by croberts@fedoraproject.org
Author: croberts
Date: 2012-12-06 15:03:59 +0000 (Thu, 06 Dec 2012)
New Revision: 5565
Modified:
trunk/wooly/python/wooly/util.py
Log:
Improvement for systems that lack the dateutil package. Our own date parsing logic will now default the year, month, day to "today" when the user enters an hour:min:sec value.
Modified: trunk/wooly/python/wooly/util.py
===================================================================
--- trunk/wooly/python/wooly/util.py 2012-12-05 19:51:42 UTC (rev 5564)
+++ trunk/wooly/python/wooly/util.py 2012-12-06 15:03:59 UTC (rev 5565)
@@ -172,7 +172,7 @@
("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"),
+ ("hour_min_sec", "HH:MM:SS", "%H:%M:%S"),
("yearfirstmonth", "YYYY-MM", "%Y-%m"),
("yearfirstday", "YYYY-MM-DD", "%Y-%m-%d"),
("yearfirsthour", "YYYY-MM-DD HH", "%Y-%m-%d %H"),
@@ -183,6 +183,10 @@
for formatname, pattern, format in formats:
try:
t_tuple = time.strptime(time_string, format)
+ if formatname == "hour_min_sec":
+ #default year, day, month to "today"
+ today = datetime.now().date()
+ t_tuple = (today.year, today.month, today.day, t_tuple.tm_hour, t_tuple.tm_min, t_tuple.tm_sec)
t = datetime(*t_tuple[:6])
except ValueError:
pass
@@ -191,5 +195,5 @@
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)))
+ % (time_string, "', '".join(s for s,p,f in formats)))
return ""
\ No newline at end of file
11 years, 5 months
r5564 - trunk/cumin/python/cumin/grid
by tmckay@fedoraproject.org
Author: tmckay
Date: 2012-12-05 19:51:42 +0000 (Wed, 05 Dec 2012)
New Revision: 5564
Modified:
trunk/cumin/python/cumin/grid/submission.py
Log:
Change Enqueued column format test to check for submissions with a queue date of
today, rather than just queue date less than 24 hours old. This allows cut and paste to work with default values for searches on the column -- a search time specified without a full date is interpreted as "today":time
Modified: trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- trunk/cumin/python/cumin/grid/submission.py 2012-12-05 18:02:58 UTC (rev 5563)
+++ trunk/cumin/python/cumin/grid/submission.py 2012-12-05 19:51:42 UTC (rev 5564)
@@ -139,7 +139,7 @@
# the whole value in the cell title on hover
d = self._get_raw_content(session, data)
if type(d) is datetime.datetime:
- if datetime.datetime.now() - d < datetime.timedelta(days=1):
+ if datetime.datetime.now().date() == d.date():
d = d.time()
else:
d = d.date()
11 years, 5 months