mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-04 04:41:35 +00:00
Three fixes (#712)
* Two fixes * Allow empty buildingId when creating/updating a resource calendar with category category_unknown * Correctly parse `csvfile <FileName>:<FieldName>` on Windows when `<FileName>` contains a drive specificatiom * Test should be against lowercase value
This commit is contained in:
20
src/gam.py
20
src/gam.py
@@ -7784,7 +7784,11 @@ def _makeBuildingIdNameMap(cd):
|
|||||||
GM_Globals[GM_MAP_BUILDING_ID_TO_NAME][building[u'buildingId']] = building[u'buildingName']
|
GM_Globals[GM_MAP_BUILDING_ID_TO_NAME][building[u'buildingId']] = building[u'buildingName']
|
||||||
GM_Globals[GM_MAP_BUILDING_NAME_TO_ID][building[u'buildingName']] = building[u'buildingId']
|
GM_Globals[GM_MAP_BUILDING_NAME_TO_ID][building[u'buildingName']] = building[u'buildingId']
|
||||||
|
|
||||||
def _getBuildingByNameOrId(cd, which_building):
|
def _getBuildingByNameOrId(cd, which_building, minLen=1):
|
||||||
|
if not which_building or which_building.lower() == u'id:':
|
||||||
|
if minLen == 0:
|
||||||
|
return u''
|
||||||
|
systemErrorExit(3, u'Building id/name is empty')
|
||||||
if which_building[:3].lower() == u'id:':
|
if which_building[:3].lower() == u'id:':
|
||||||
return which_building[3:]
|
return which_building[3:]
|
||||||
if GM_Globals[GM_MAP_BUILDING_NAME_TO_ID] is None:
|
if GM_Globals[GM_MAP_BUILDING_NAME_TO_ID] is None:
|
||||||
@@ -7905,7 +7909,7 @@ def _getResourceCalendarAttributes(cd, args, body={}):
|
|||||||
body[u'resourceType'] = args[i+1]
|
body[u'resourceType'] = args[i+1]
|
||||||
i += 2
|
i += 2
|
||||||
elif myarg in [u'building', u'buildingid']:
|
elif myarg in [u'building', u'buildingid']:
|
||||||
body[u'buildingId'] = _getBuildingByNameOrId(cd, args[i+1])
|
body[u'buildingId'] = _getBuildingByNameOrId(cd, args[i+1], minLen=0)
|
||||||
i += 2
|
i += 2
|
||||||
elif myarg in [u'capacity']:
|
elif myarg in [u'capacity']:
|
||||||
body[u'capacity'] = int(args[i+1])
|
body[u'capacity'] = int(args[i+1])
|
||||||
@@ -10876,7 +10880,7 @@ def doPrintCrosDevices():
|
|||||||
orderBy = u'lastSync'
|
orderBy = u'lastSync'
|
||||||
elif orderBy == u'serialnumber':
|
elif orderBy == u'serialnumber':
|
||||||
orderBy = u'serialNumber'
|
orderBy = u'serialNumber'
|
||||||
elif orderBy == u'supportEndDate':
|
elif orderBy == u'supportenddate':
|
||||||
orderBy = u'supportEndDate'
|
orderBy = u'supportEndDate'
|
||||||
i += 2
|
i += 2
|
||||||
elif myarg in SORTORDER_CHOICES_MAP:
|
elif myarg in SORTORDER_CHOICES_MAP:
|
||||||
@@ -11315,13 +11319,11 @@ def getUsersToModify(entity_type=None, entity=None, silent=False, member_type=No
|
|||||||
users.append(user)
|
users.append(user)
|
||||||
closeFile(f)
|
closeFile(f)
|
||||||
elif entity_type in [u'csv', u'csvfile']:
|
elif entity_type in [u'csv', u'csvfile']:
|
||||||
try:
|
drive, filenameColumn = os.path.splitdrive(entity)
|
||||||
(filename, column) = entity.split(u':')
|
if filenameColumn.find(u':') == -1:
|
||||||
except ValueError:
|
|
||||||
filename = column = None
|
|
||||||
if (not filename) or (not column):
|
|
||||||
systemErrorExit(2, u'Expected {0} FileName:FieldName'.format(entity_type))
|
systemErrorExit(2, u'Expected {0} FileName:FieldName'.format(entity_type))
|
||||||
f = openFile(filename, mode='rbU')
|
(filename, column) = filenameColumn.split(u':')
|
||||||
|
f = openFile(drive+filename, mode='rbU')
|
||||||
input_file = csv.DictReader(f, restval=u'')
|
input_file = csv.DictReader(f, restval=u'')
|
||||||
if column not in input_file.fieldnames:
|
if column not in input_file.fieldnames:
|
||||||
csvFieldErrorExit(column, input_file.fieldnames)
|
csvFieldErrorExit(column, input_file.fieldnames)
|
||||||
|
|||||||
Reference in New Issue
Block a user