Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:06

0001 import json
0002 import sys
0003 
0004 # special permission
0005 PERMISSION_KEY = "k"
0006 PERMISSION_PROXY = "p"
0007 PERMISSION_TOKEN_KEY = "t"
0008 PERMISSION_SUPER_USER = "s"
0009 PERMISSION_SUPER_GROUP = "g"
0010 
0011 
0012 # convert UTF-8 to ASCII in json dumps
0013 # This is needed for Python 2, but not for Python 3
0014 def unicodeConvert(input):
0015     if isinstance(input, dict):
0016         retMap = {}
0017         for tmpKey in input:
0018             tmpVal = input[tmpKey]
0019             retMap[unicodeConvert(tmpKey)] = unicodeConvert(tmpVal)
0020         return retMap
0021     elif isinstance(input, list):
0022         retList = []
0023         for tmpItem in input:
0024             retList.append(unicodeConvert(tmpItem))
0025         return retList
0026     elif isinstance(input, str) and sys.version_info[0] == 2:
0027         return input.encode("utf-8")
0028     return input
0029 
0030 
0031 # decode
0032 # This is needed for Python 2, but not for Python 3
0033 def decodeJSON(inputStr):
0034     return json.loads(inputStr, object_hook=unicodeConvert)
0035 
0036 
0037 # calculate priority for user jobs
0038 def calculatePriority(priorityOffset, serNum, weight):
0039     priority = int(1000 + priorityOffset - (serNum / 5) - int(100 * weight))
0040     return priority