git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value...
[plcapi.git]
/
PLC
/
Leases.py
diff --git
a/PLC/Leases.py
b/PLC/Leases.py
index
cb8eed6
..
9da3d3b
100644
(file)
--- a/
PLC/Leases.py
+++ b/
PLC/Leases.py
@@
-1,8
+1,6
@@
#
# Functions for interacting with the leases table in the database
#
#
# Functions for interacting with the leases table in the database
#
-# $Id$
-# $URL$
# Thierry Parmentelat -- INRIA
#
# Thierry Parmentelat -- INRIA
#
@@
-52,18
+50,19
@@
class Lease(Row):
# retrieve configured granularity
granularity = self.api.config.PLC_RESERVATION_GRANULARITY
# the trick for rounding up rather than down
# retrieve configured granularity
granularity = self.api.config.PLC_RESERVATION_GRANULARITY
# the trick for rounding up rather than down
- if round_up: timestamp += (granularity-1)
+ if round_up:
+ timestamp += (granularity-1)
# round down
# round down
- timestamp = (timestamp
/
granularity) * granularity
+ timestamp = (timestamp
//
granularity) * granularity
# return a SQL string
return Timestamp.sql_validate_utc(timestamp)
# return a SQL string
return Timestamp.sql_validate_utc(timestamp)
- # round UP
- def validate_t_from(self,timestamp):
- return self.validate_time
(timestamp, round_up=True)
- # round DOWN
+ # round UP
+ def validate_t_from(self,
timestamp):
+ return self.validate_time(timestamp, round_up=True)
+ # round DOWN
def validate_t_until (self, timestamp):
def validate_t_until (self, timestamp):
- return self.validate_time
(timestamp, round_up=False)
+ return self.validate_time(timestamp, round_up=False)
class Leases(Table):
"""
class Leases(Table):
"""
@@
-76,19
+75,16
@@
class Leases(Table):
# the view that we're selecting upon: start with view_leases
view = "view_leases"
# the view that we're selecting upon: start with view_leases
view = "view_leases"
- sql = "SELECT %s FROM %s WHERE true" % (", ".join(
self.columns.keys(
)),view)
+ sql = "SELECT %s FROM %s WHERE true" % (", ".join(
list(self.columns.keys()
)),view)
if lease_filter is not None:
if lease_filter is not None:
-
- if isinstance (lease_filter, int):
- lease_filter = Filter (Lease.fields, {'lease_id': lease_filter})
- elif isinstance(lease_filter, (list, tuple, set)):
+ if isinstance(lease_filter, (list, tuple, set, int)):
lease_filter = Filter(Lease.fields, {'lease_id': lease_filter})
elif isinstance(lease_filter, dict):
lease_filter = LeaseFilter(Lease.fields, lease_filter)
else:
lease_filter = Filter(Lease.fields, {'lease_id': lease_filter})
elif isinstance(lease_filter, dict):
lease_filter = LeaseFilter(Lease.fields, lease_filter)
else:
- raise PLCInvalidArgument
, "Wrong lease filter %r"%lease_filter
+ raise PLCInvalidArgument
("Wrong lease filter %r"%lease_filter)
sql += " AND (%s) %s" % lease_filter.sql(api)
self.selectall(sql)
sql += " AND (%s) %s" % lease_filter.sql(api)
self.selectall(sql)