def parse_dl(dbq): dlurl = Const.url() + dbq.replace(' ', '/', 1) dlurl = dlurl.replace(' ', '-') + '.zip' dldir = Const.gdldir() + dbq[:dbq.find(' ')] + '\\' dlpath = dldir + dlurl.split('/')[-1] m = "downloading " + dlurl + " to " + dlpath + '...' return (dlurl, dldir, dlpath, m)
def __init__(self, mark: int, fromRow: int, fromCol: int, toRow: int, toCol: int): if mark == Const.MARK_NONE: raise ValueError(f"mark must be goat or tiger") Const.markOk(mark) Const.rowOk(fromRow) Const.colOk(fromCol) Const.rowOk(toRow) Const.colOk(toCol) self._mark: int = mark self._fromRow: int = fromRow self._fromCol: int = fromCol self._toRow: int = toRow self._toCol: int = toCol dist: int = max(abs(toRow - fromRow), abs(toCol - fromCol)) diagonal : bool = \ (fromRow + fromCol) % 2 == 0 and \ (toRow + toCol) % 2 == 0 and \ (abs(fromRow-toRow) == abs(fromCol-toCol)) straight : bool = (fromRow == toRow) or \ (fromCol == toCol) if (not straight) and (not diagonal): raise ValueError("impossible move") if mark == Const.MARK_GOAT: if dist > 1: raise ValueError("goats can only place or move 1") elif dist < 1 or dist > 2: raise ValueError("tigers can only move 1 or 2 (capture)")
def __init__(self, a=0.3, M_c=5): self.con = Const(a, M_c) self.values = [] self.dValues = [] self.dr = 0.0 self.num = 1000 self.f = []
def split_triple_number(): const = Const() const.novel_tagging() data = utils.read_json(Const.raw_test_filename) # sentences contains 1, 2, 3, 4, and >5 triples triples_size_1_data, triples_size_2_data, triples_size_3_data, triples_size_4_data, triples_size_5_data = [], [], [], [], [] for i, a_data in enumerate(data): triples = set() for triple in a_data['relationMentions']: m1 = nltk.word_tokenize(triple['em1Text'])[-1] m2 = nltk.word_tokenize(triple['em2Text'])[-1] label = triple['label'] if label != 'None': triples.add((m1, m2, label)) if len(triples) == 1: triples_size_1_data.append(a_data) elif len(triples) == 2: triples_size_2_data.append(a_data) elif len(triples) == 3: triples_size_3_data.append(a_data) elif len(triples) == 4: triples_size_4_data.append(a_data) else: triples_size_5_data.append(a_data) utils.write_data(open(const.raw_test_1_triple_filename, 'w'), triples_size_1_data) utils.write_data(open(const.raw_test_2_triple_filename, 'w'), triples_size_2_data) utils.write_data(open(const.raw_test_3_triple_filename, 'w'), triples_size_3_data) utils.write_data(open(const.raw_test_4_triple_filename, 'w'), triples_size_4_data) utils.write_data(open(const.raw_test_5_triple_filename, 'w'), triples_size_5_data) print 'Sentence-1-Triple: %d' % len(triples_size_1_data) print 'Sentence-2-Triple: %d' % len(triples_size_2_data) print 'Sentence-3-Triple: %d' % len(triples_size_3_data) print 'Sentence-4-Triple: %d' % len(triples_size_4_data) print 'Sentence-5-Triple: %d' % len(triples_size_5_data)
def split_triple_type(): const = Const() const.novel_tagging() data = utils.read_json(Const.raw_test_filename) normal_triple_data = [] multi_label_data = [] over_lapping_data = [] for i, a_data in enumerate(data): triples = a_data['relationMentions'] triples_ = set() for triple in triples: m1 = nltk.word_tokenize(triple['em1Text'])[-1] m2 = nltk.word_tokenize(triple['em2Text'])[-1] label = triple['label'] if label != 'None': triples_.add((m1, m2, label)) triples = [] for t in triples_: triples.extend(list(t)) if utils.is_normal_triple(triples, is_relation_first=False): normal_triple_data.append(a_data) if utils.is_multi_label(triples, is_relation_first=False): multi_label_data.append(a_data) if utils.is_over_lapping(triples, is_relation_first=False): over_lapping_data.append(a_data) print('Number of normal triple data %s' % len(normal_triple_data)) print('Number of multi triple data %s' % len(multi_label_data)) print('Number of overlapping triple data %s' % len(over_lapping_data)) utils.write_data(open(const.raw_test_normal_triple_filename, 'w'), normal_triple_data) utils.write_data(open(const.raw_test_multi_label_filename, 'w'), multi_label_data) utils.write_data(open(const.raw_test_overlapping_filename, 'w'), over_lapping_data)
def parse_uninstl_spaar(dbq): us = Const.unity_script() us_bkp = '-bkp'.join([us[:-4], us[-4:]]) jsonf = Const.cd() + 'Mods\\Config\\modLoader.json' m1 = 'removing modded Assembly-UnityScript.dll...' m2 = 'restoring backup of Assembly-UnityScript.dll...' m3 = 'romoving ' + jsonf + '...' return (us, us_bkp, jsonf, m1, m2, m3)
def parse_instl(dbq): dlpath = Const.gdldir() + dbq[1] + '\\' + dbq[2] + '-' + dbq[3] + '.zip' instldir = Const.instldir() tmparr = dlpath.split('\\') tmparr[-1] = 'installed_' + tmparr[-1] tag_dlpath = '\\'.join(tmparr) m = 'installing ' + dlpath + ' to ' + instldir + '...' return (dlpath, instldir, tag_dlpath, m)
def parse_instl_spaar(): us = Const.unity_script() us_bkp = '-bkp'.join([us[:-4], us[-4:]]) instldir = Const.instldir() us_instlpath = instldir + 'Assembly-UnityScript.dll' m1 = 'backing up Assembly-UnityScript.dll...' m2 = 'copying the modded dll...' return (us, us_bkp, us_instlpath, m1, m2)
def parse_uninstl_spaar(dbq): us = Const.unity_script() us_bkp = '-bkp'.join([us[:-4],us[-4:]]) jsonf = Const.cd() + 'Mods\\Config\\modLoader.json' m1 = 'removing modded Assembly-UnityScript.dll...' m2 = 'restoring backup of Assembly-UnityScript.dll...' m3 = 'romoving ' + jsonf + '...' return (us, us_bkp, jsonf, m1, m2, m3)
def parse_uninstl(dbq): dbq = dbq[:-21] dbq = dbq.replace(' ', '\\installed_', 1) dbq = dbq.replace(' ', '-') dlpath = Const.gdldir() + dbq + '.zip' instldir = Const.instldir() untag_dlpath = dlpath.replace('installed_', '') return (dlpath, instldir, untag_dlpath)
def parse_instl_spaar(): us = Const.unity_script() us_bkp = '-bkp'.join([us[:-4],us[-4:]]) instldir = Const.instldir() us_instlpath = instldir + 'Assembly-UnityScript.dll' m1 = 'backing up Assembly-UnityScript.dll...' m2 = 'copying the modded dll...' return (us, us_bkp, us_instlpath, m1, m2)
def __str__(self) -> str: if self.placement: return Const.markStr( self._mark) + chr(ord('a') + self._toRow) + chr(ord('1') + self._toCol) else: return Const.markStr( self._mark) + chr(ord('a') + self._fromRow) + chr( ord('1') + self._fromCol) + '-' + chr( ord('a') + self._toRow) + chr(ord('1') + self._toCol)
def __str__(self) -> str: ans = "\n" ans = ans + "turn " + str(self._turns) + "(" + Const.stateStr(self.state) + "):\n" for row in range(Const.ROWS): s="" for col in range(Const.COLS): s=s+Const.markStr(self._board[row][col]) ans = ans + s + "\n" return ans
def __init__(self, width, height, border): self.button_data = Const() self.button_data.width = 100 self.button_data.large_width = self.button_data.width * 2 self.button_data.height = 50 ## Spread buttons out between sweep and edge self.button_data.done_x = border.inner_x() + Widths.BORDER self.button_data.cancel_x = width - Widths.BORDER - self.button_data.large_width self.button_data.pay_x = (self.button_data.done_x + self.button_data.cancel_x) / 2 self.button_data.y = height - Widths.BORDER - self.button_data.height # Put buttons at bottom of screen ## Put the top bar below the sweep self.top_bar = Const() self.top_bar.x = border.inner_x() + Widths.BORDER self.top_bar.y = border.inner_y() + Widths.BORDER ## This allows caculation of the inner width of the useable screen area self.inner_width = width - self.top_bar.x - Widths.BORDER ## And then the small amount bar can be defined self.amount = Const() self.amount.y = self.top_bar.y self.amount.width = 2 * self.button_data.width self.amount.x = width - Widths.BORDER - self.amount.width ## And finally the top bar width can be defined self.top_bar.width = self.inner_width - self.amount.width - Widths.BORDER ## The first product entry starts below the top bar self.product_entries = Const() self.product_entries.top_y = self.top_bar.y + self.button_data.height + Widths.BORDER # The up/dn scroll buttons cover the whole height of the screen scroll_height = (self.button_data.y - self.product_entries.top_y) / 2 scroll_height -= Widths.BORDER self.scroll = Const() self.scroll.height = scroll_height self.scroll.width = self.button_data.height self.scroll.x = width - Widths.BORDER - self.scroll.width self.scroll.up_y = self.product_entries.top_y self.scroll.dn_y = self.scroll.up_y + self.scroll.height + Widths.BORDER # Position constants for product objects self.product_entries.desc_x = self.top_bar.x self.product_entries.desc_w = self.button_data.large_width * 1.8 self.product_entries.price_x = self.product_entries.desc_x + self.product_entries.desc_w + Widths.BORDER self.product_entries.price_w = self.button_data.large_width / 2 self.product_entries.remove_x = self.product_entries.price_x + self.product_entries.price_w + Widths.BORDER self.product_entries.row_h = self.button_data.height + 20
def parse_instl(dbq): dbq = dbq[:-11] dbq = dbq.replace(' ', '\\', 1) dbq = dbq.replace(' ', '-') dlpath = Const.gdldir() + dbq + '.zip' instldir = Const.instldir() tmparr = dlpath.split('\\') tmparr[-1] = 'installed_' + tmparr[-1] tag_dlpath = '\\'.join(tmparr) m = 'installing ' + dlpath + ' to ' + instldir + '...' return (dlpath, instldir, tag_dlpath, m)
def parse_rm(dbq): dbq = dbq[:-11] dbq = dbq.replace(' ', '\\', 1) dbq = dbq.replace(' ', '-') dlpath = Const.gdldir() + dbq + '.zip' m = 'removing ' + dlpath + '...' return (dlpath, m)
def top_to_tile(top, tile, tile_idx): tile.add_ports(tile_id=magma.In(magma.Bits(16))) top.wire(Const(magma.bits(tile_idx, 16)), tile.tile_id) tile_eq = FromMagma(mantle.DefineEQ(16)) tile.wire(tile.tile_id, tile_eq.I0) tile.wire(tile.config.config_addr[0:16], tile_eq.I1) return tile_eq
def __init__(self): self.config = Config() # setup variables self.const = Const() # Set logging level and info logging.basicConfig(level=self.config.LOG_LEVEL, format=self.const.LOG_FORMAT)
def __init__(self): super().__init__() self.add_ports( O=magma.Out(magma.Bits(16)), ) self.wire(Const(magma.bits(0, 16)), self.O)
def tile_to_feature(tile, tile_eq, feature, feature_idx): feature.add_ports(config_en=magma.In(magma.Bit)) feature_eq = FromMagma(mantle.DefineEQ(8)) tile.wire(tile.config.config_addr[16:24], feature_eq.I0) tile.wire(Const(magma.bits(feature_idx, 8)), feature_eq.I1) feature_en = FromMagma(mantle.DefineAnd()) tile.wire(feature_eq.O, feature_en.I0) tile.wire(tile_eq.O, feature_en.I1) tile.wire(feature_en.O, feature.config_en)
def __init__(self): # Config and setup self.const = Const() self.config = Config() locale.setlocale(locale.LC_TIME, self.config.LOCALE) # Set logging level and info logging.basicConfig(level=self.config.LOG_LEVEL, format=self.const.LOG_FORMAT) self.covidHandler = CovidHandler() self.temperatureHandler = TemperatureHandler()
def __init__(self): self.config = Config() # Set logging level and info logging.basicConfig( level=self.config.LOG_LEVEL, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') self.database = mysql.connector.connect(host=self.config.DBHOST, database=self.config.DBNAME, user=self.config.DBUSER, password=self.config.DBPASSWD) self.cursor = self.database.cursor() self.const = Const()
def local(): # walk the downloads dir # build the local database gdldir = Const.gdldir() dirs = os.listdir(gdldir) localdb = [] i = 0 for d in dirs: fpath = gdldir + d files = os.listdir(fpath) for f in files: localdb = Parser.parse_localdb(localdb, d, f, i) i += 1 return (localdb)
def tile_to_feature(tile, tile_eq, feature, feature_idx): feature.add_ports( config=magma.In(ConfigurationType(8, 32)), config_en=magma.In(magma.Bit), ) tile.wire(tile.config.config_addr[24:], feature.config.config_addr) tile.wire(tile.config.config_data, feature.config.config_data) feature_eq = FromMagma(mantle.DefineEQ(8)) tile.wire(tile.config.config_addr[16:24], feature_eq.I0) tile.wire(Const(magma.bits(feature_idx, 8)), feature_eq.I1) feature_en = FromMagma(mantle.DefineAnd()) tile.wire(feature_eq.O, feature_en.I0) tile.wire(tile_eq.O, feature_en.I1) tile.wire(feature_en.O, feature.config_en)
def turn(self) -> None: if self._game.over: if self._verbose: print("game over - " + Const.stateStr(game.state)) print(game) return move = self.propose() self._game.play(move) if not self._fast: self._shadowGame.moveOk(move) self._shadowGame.play(move) if self._game != self._shadowGame: raise ValueError("game and shadow out of sync") if self._verbose: print("after move " + str(move) + ":") print(self._game)
def __init__(self, product): self.product = product self.formats = Const() self.formats.desc_pence = "%s (%dp)" self.formats.desc_pounds = u"%s (\xA3%.2f)" self.formats.price_pence = "%dp" self.formats.price_pounds = "\xA3%.2f" self.lcars_objects = [None] * 3 self.description = '' self.price_string = '' self.visible = True
def updateData(brokerName, list): sql = "insert into price values" const = Const.Const() for k in list.keys(): pattern = r"[0-9\.]+" matchlist = re.findall(pattern, list[k]) b = matchlist[0] a = matchlist[1] s = round((float(a) - float(b)) * 100000) / 100000 sql = sql + "('" + brokerName + "','" + k + "'," + str(b) + "," + str(a) + "," + str(s) + ", current_timestamp)," sql = sql[0:-1] + ";" db = Db.Db() db.execute(const.POSTGRE_HOST, const.POSTGRE_PORT, const.POSTGRE_DB, const.POSTGRE_USER, const.POSTGRE_PW, "delete from price where broker='" + brokerName + "';") db.execute(const.POSTGRE_HOST, const.POSTGRE_PORT, const.POSTGRE_DB, const.POSTGRE_USER, const.POSTGRE_PW, sql)
def local(): # walk the downloads dir # build the local database gdldir = Const.gdldir() DirCreator.dirExistCheck(gdldir) dirs = os.listdir(gdldir) localdb = [] i = 0 for d in dirs: fpath = gdldir + d try: files = os.listdir(fpath) except: files = [] for f in files: localdb = Parser.parse_lcldb(localdb, d, f, i) i += 1 return (localdb)
def local(): # walk the downloads dir # build the local database gdldir = Const.gdldir() DirCreator.dirExistCheck(gdldir) dirs = os.listdir(gdldir) localdb = [] i = 0 for d in dirs: fpath = gdldir + d try: files = os.listdir(fpath) except: files = [] for f in files: localdb = Parser.parse_lcldb(localdb, d, f, i) i += 1 return localdb
def test_simple_kernel(self): """ Implement a simple kernel. """ for case in self.cases: # Form data to work on. space.initialize_space(case['shape']) x_np = comm.allreduce( np.random.randn(*case['shape']).astype(case['dtype'])) x = Grid(x_np, x_overlap=2) s_np = comm.allreduce( np.random.randn(case['shape'][0], 1, 1).astype(case['dtype'])) s = Const(s_np) z = Out(case['dtype']) # Make a kernel. code = Template(""" if (_in_local && _in_global) { z += a * s(_X) * x(0,0,0); // z += a * x(0,0,0); } """).render() fun = Kernel(code, \ ('a', 'number', case['dtype']), \ ('x', 'grid', x.dtype), \ ('s', 'const', s.dtype), \ ('z', 'out', z.dtype), \ shape_filter='all') # Execute and check the result. # fun() while fun.exec_configs: # for k in range(40): fun(case['dtype'](2.0), x, s, z) # fun(case['dtype'](2.0), x, z) gpu_sum = z.get() cpu_sum = np.sum(2 * s_np * x_np) # cpu_sum = np.sum(2 * x_np) err = abs(gpu_sum - cpu_sum) / abs(cpu_sum) if case['dtype'] in (np.float32, np.complex64): self.assertTrue(err < 1e-2, (case, err)) else: self.assertTrue(err < 1e-6, (case, err))
def build(): # connect to online database # print ('\nID CATEGORY NAME VERSION DOWNLOADED? INSTALLED?') onlinedb = urllib.request.urlopen(Const.dburl()) localdb = Database.local() i = 0 db = [] for line in onlinedb: line = str(line) e = line.find('\\') db.append(line[2:e]) for j in range(len(localdb)): if db[i] == localdb[j]: db[i] += ' downloaded' break elif db[i] + ' installed' == localdb[j]: db[i] += ' downloaded installed' break print (str(i) + ' ' + db[i]) i += 1 return (db)
def build(): m = ['CATEGORY', 'NAME', 'VERSION', 'DOWNLOADED?', 'INSTALLED?'] print(m) localdb = Database.local() mode = '' # try connecting to online database try: onlinedb = urllib.request.urlopen(Const.dburl()) i = 0 db = [] for line in onlinedb: line = str(line) e = line.find('\\') db.append(line[2:e]) for j in range(len(localdb)): if db[i] == localdb[j]: db[i] += ' downloaded' break elif db[i] + ' installed' == localdb[j]: db[i] += ' downloaded installed' break db[i] = db[i].split() db[i] = [str(i)] + db[i] print(db[i]) i += 1 mode = 'online' # if connection fails, use local database except: db = localdb for i in range(len(db)): db[i] = db[i].split() db[i] = [str(i)] + db[i] db[i].insert(4, 'downloaded') print(db[i]) mode = 'offline' return (db, mode)
def build(): m = ["CATEGORY", "NAME", "VERSION", "DOWNLOADED?", "INSTALLED?"] print(m) localdb = Database.local() mode = "" # try connecting to online database try: onlinedb = urllib.request.urlopen(Const.dburl()) i = 0 db = [] for line in onlinedb: line = str(line) e = line.find("\\") db.append(line[2:e]) for j in range(len(localdb)): if db[i] == localdb[j]: db[i] += " downloaded" break elif db[i] + " installed" == localdb[j]: db[i] += " downloaded installed" break db[i] = db[i].split() db[i] = [str(i)] + db[i] print(db[i]) i += 1 mode = "online" # if connection fails, use local database except: db = localdb for i in range(len(db)): db[i] = db[i].split() db[i] = [str(i)] + db[i] db[i].insert(4, "downloaded") print(db[i]) mode = "offline" return (db, mode)
def test_padded_kernel(self): """ Implement a simple padded kernel. """ for case in self.cases: # Form data to work on. space.initialize_space(case['shape']) x_np = comm.allreduce( np.random.randn(*case['shape']).astype(case['dtype'])) x = Grid(x_np, x_overlap=1) s_np = comm.allreduce(np.random.randn(1).astype(case['dtype'])) s = Const(s_np) z = Out(case['dtype']) # Make a kernel. code = Template(""" if (_in_local && _in_global) { x(0,0,0) = s(0) * x(0,0,0); z += a * x(0,0,0); } """).render() fun = Kernel(code, \ ('a', 'number', case['dtype']), \ ('x', 'grid', x.dtype), \ ('s', 'const', s.dtype, s.data.size), \ ('z', 'out', z.dtype), \ padding=(1,1,1,1)) # Execute and check the result. fun(case['dtype'](2), x, s, z) gpu_sum = z.get() cpu_sum = np.sum(2.0 * s_np * x_np) err = abs(gpu_sum - cpu_sum) / abs(cpu_sum) # print case, err if case['dtype'] in (np.float32, np.complex64): self.assertTrue(err < 1e-2, (case, err)) else: self.assertTrue(err < 1e-6, (case, err))
Where packettype is the context of the packet data("transaction", "getuser", "ping" etc.) and datatype is the context of the individual data items enclosed, e.g <barcode>12345</barcode> This file is responsible for pushing data to/from Python data structures and XML DOM objects. ''' from xml.dom.minidom import parseString from xml.dom.minidom import getDOMImplementation from const import Const ## Constants defining packet types PacketTypes = Const() PacketTypes.Ping = "ping" PacketTypes.PingReply = "pingreply" PacketTypes.GetRandomProduct = "randomproduct" PacketTypes.AddCredit = "addcredit" PacketTypes.AddProduct = "addproduct" PacketTypes.Transaction = "transaction" PacketTypes.GetUser = "******" PacketTypes.GetProduct = "getproduct" PacketTypes.ProductData = "productdata" PacketTypes.UserData = "userdata" PacketTypes.UnknownProduct = "unknownproduct" PacketTypes.UnknownUser = "******" PacketTypes.RandomProduct = "randomproduct" PacketTypes.Result = "result"
def main(*args): inputDir = './data.1d' prjName = 'Prcp_GPCC' xIdx,yIdx = 100,140 sDTime = datetime.datetime(2000,1,1,0,0) eDTime = datetime.datetime(2001,1,1,0,0) dT = datetime.timedelta(seconds=3600*6) # totSec = (eDTime-sDTime).days*86400+(eDTime-sDTime).seconds # dTsec = dT.days*86400+dT.seconds totSec = (eDTime-sDTime).total_seconds() # in float (not int) dTsec = dT.total_seconds() nTLoop = int(totSec/dTsec) vegType = 'crop' C = Const(vegType) C.dT = dT.seconds C.dT = 600. varNAME = [ 'CCOV', 'LWdown', 'PSurf', 'Prcpf', 'Qair', # 2m Specific Humidity [kg/kg] 'Rainf', 'SWdown', 'Snowf', 'Tair', # 2m Air Temperature [K] 'Wind' # Wind Speed [m/s] ] # Open Input Files -------------------------------------------------------- dInFile = dict( (var,file(os.path.join( inputDir, '%s.%s.%i@%ix%i.asc'%(prjName,var,sDTime.year,yIdx,xIdx) ))) for var in varNAME) # -------------------------------------------------------------------------- # Declare State Variables dVarState = { 'Ts':243.15, # Skin Temp. 'Td':244.15, # Soil Temp. } tmpOUT = {'Rnet':[], 'ET0' :[], 'H' :[], 'Td' :[], 'Ts' :[],} # Time integration loop --------------------------------------------------- for ii,nLoop in enumerate(xrange(nTLoop)): dVarIn = dict((var,float(dInFile[var].readline())) for var in varNAME) # Epot = calc_Epot(C,dVarIn) # print '%5.2f'%(Epot*86400), # Read State Variable ------------------------------------------------- Ts = dVarState['Ts'] # Skin Temp. [K] Td = dVarState['Td'] # Soil Temp. [K] # --------------------------------------------------------------------- # Read Forcing Variable ----------------------------------------------- U10 = dVarIn['Wind'] # 10m wind speed [m/s] T2 = dVarIn['Tair'] # 2m air temp. [K] Q2 = dVarIn['Qair'] # 2m specific humidity [??] P = dVarIn['PSurf'] # surface pressure [hPa] RSDN = dVarIn['SWdown'] # downward solar rad. [W/m**2] RLDN = dVarIn['LWdown'] # downward solar rad. [W/m**2] # --------------------------------------------------------------------- RSUP = RSDN*C.Veg['albedo'] # upward solar rad. [W/m**2] RLUP = C.sig*Ts**4 # upward solar rad. [W/m**2] Rnet = RSDN-RSUP+RLDN-RLUP U2 = calc_Whgt(U10,10.,2.,C.Veg['roughLenM']) # calc. 2m wind speed slpVP = calc_slopeVP(T2) gamma = calc_psycho(P) R_a = r_a(U2,C,obsHgtU=2.) R_s = r_s(C) # print dVarIn['Wind'],U10,r_a(U2,C,obsHgtU=2.),207.66407000788683/U2,69.44444444 # print T2,U10,R_a,R_s,RSDN,RSUP,RLDN,RLUP,Rnet,gamma # ET0 = calc_ET0(C,slpVP,Rnet,0.,gamma,T2,U2,Q2,P) ET0 = calc_Epot(C,dVarIn,dVarState,Esat_scheme='goff') H = calc_H(C,dVarIn,dVarState) # print '#',ii,Rnet,RSDN,RSUP,RLDN,RLUP,T2,ET0,H,Ts,Td # if ii > 10: sys.exit() print '***Ts***:',dVarState['Ts'] dVarState['Td'] = update_Td(C,dVarState,Rnet,ET0,H) dVarState['Ts'] = update_Ts(C,dVarState,Rnet,ET0,H) print '***Ts_nxt***:',dVarState['Ts'] tmpOUT['Rnet'].append(Rnet) tmpOUT['ET0'].append(ET0) tmpOUT['H' ].append(H) tmpOUT['Td' ].append(dVarState['Td']) tmpOUT['Ts' ].append(dVarState['Ts']) return tmpOUT
def parse_uninstl(dbq): dlpath = Const.gdldir( ) + dbq[1] + '\\' + dbq[5] + '_' + dbq[2] + '-' + dbq[3] + '.zip' instldir = Const.instldir() untag_dlpath = dlpath.replace('installed_', '') return (dlpath, instldir, untag_dlpath)
display_constants.py Constant values for layout, color, etc. pylint message C0103 disabled due to requiring UPPERCASE identifiers for constants and Proper Case for classes/collections """ from enum import Enum from const import Const # Available snackspace screens Screens = Enum("BLANKSCREEN", "INTROSCREEN", "MAINSCREEN", "NUMERICENTRY", "PRODUCTENTRY", "WAITING") #pylint: disable=C0103 # Global widths for LCARS style interface Widths = Const() #pylint: disable=C0103 Widths.BORDER = 20 #pylint: disable=W0201,C0103 Widths.LARGE_BAR = 60 #pylint: disable=W0201,C0103 Widths.SMALL_BAR = 30 #pylint: disable=W0201,C0103 # Global colour pallette Colours = Const() #pylint: disable=C0103 Colours.BG = ( 0, 0, 0) #pylint: disable=W0201,C0103 Colours.FG = ( 40, 89, 45) #pylint: disable=W0201,C0103 Colours.WARN = (255, 255, 0) #pylint: disable=W0201,C0103 Colours.ERR = (255, 0, 0) #pylint: disable=W0201,C0103 Colours.INFO = ( 0, 255, 0) #pylint: disable=W0201,C0103 Colours.ENTRY = ( 0, 128, 0) #pylint: disable=W0201,C0103 # Name of sound file for touchscreen press SOUNDFILE = "press_sound.ogg"
def __init__(self, args): global LOG self.args = args.strip() self.settings = Const.load_application_settings() wf = Workflow() LOG = wf.logger
def parse_rm(dbq): dlpath = Const.gdldir( ) + dbq[1] + '\\' + dbq[2] + '-' + dbq[3] + '.zip' m = 'attempting to remove ' + dlpath + '...' return (dlpath, m)
def __init__(self, args): self.args = args.strip() self.settings = Const.load_application_settings()
def parse_dl(dbq): dlurl = Const.url() + dbq[1] + '/' + dbq[2] + '-' + dbq[3] + '.zip' dldir = Const.gdldir() + dbq[1] + '\\' dlpath = dldir + dlurl.split('/')[-1] m = "attempting to download " + dlurl + " to " + dlpath + '...' return (dlurl, dldir, dlpath, m)