def callJSONRPCServer(self,bmcPluginName): bmcUtil = Util() bmcUtil.setValue(bmcPluginName) bmcHostName = bmcUtil.readLocalAppVariableFile("BMC_JSONRPCCALL_HOST_NAME") bmcPortNumber = bmcUtil.readLocalAppVariableFile("BMC_JSON_RPCCALL_PORT_NUMBER") #Running run_simple(bmcUtil.removeDoubleQuotas(bmcHostName), bmcPortNumber, self.application)
def __init__(self): self.r_rules_dict = {} self.r_model_dict = {} self.util = Util() self.logger = ALogger("Graph", True).getLogger()
def main(): #setup util functions DEBUG = False PRINT = True util = Util(DEBUG, PRINT) #easy access to print funcs uprt = util.outPrt uerr = util.errPrt #read in data from csv data = pd.read_csv("./btc.csv") #print columns uprt("Columns", data.columns.values.tolist()) #pull out target column y = data["PriceUSD"] X = data.loc[:, data.columns != "PriceUSD"] #split dataset xtrain, xtest, ytrain, ytest = split(X, y) #print split data sets uprt("\nxtrain:", xtrain) uprt("\nytrain:", ytrain) uprt("\nxtest:", xtest) uprt("\nytest:", ytest)
def do_diario(self, buffer, arquivo): print(arquivo) #diario_pattern = re.compile('Ano\s(\w{3}|\w{4}|\w{5}|\w{6})\s•\sN\w\s(\d{3})') diario_pattern = re.compile('Ano\s([A-Z]*)\s•\sN\w\s([0-9]*)') diario_edicao = diario_pattern.search(buffer) print(diario_edicao.group(1)) print("Arquivo->" + arquivo + '\n') #Diário Suplementar diario_suplemento_pattern = re.compile( 'Diário Oficial do Município do Rio de Janeiro\s\|\s\w*\s\w*\s\|\s\w*\s\w*\s\|\s(Suplemento)' ) diario_suplemento = diario_suplemento_pattern.search(buffer) if diario_suplemento: tipo = 2 #Suplemento else: tipo = 1 #Normal util = Util() diario = Diario() RioDAO = RioJaneiroDAO() diario.anoromano = (diario_edicao.group(1)) diario.ano = (util.converteRomano(diario_edicao.group(1))) diario.numero = (diario_edicao.group(2)) diario.nomearquivo = None #str(arquivo) diario.datadiario = None #Colocar aqui a informação correta da data do diário diario.tipo = (tipo) diario.identidade = None #int(1) #Codigo provisorio do Rio de Janeiro diario.datagravacao = None #Colocar aqui uam finção de data atual do sistema RioDAO.gravaDiario(diario)
def __init__(self, year=None, month=1, day=1, hour=0, minute=0, second=0, millisecond=0): if year == None: localtime = str( datetime.now(timezone.utc).astimezone( pytz.timezone("Africa/Addis_Ababa"))) lst_now = self._parse(str(localtime)) year, month, day = lst_now[0], lst_now[1], lst_now[2] Ethiopia_day = util.Util().gregorianToEthiopic(year, month, day) self.__year = Ethiopia_day[0] else: self.__year = year self.__month = month self.__day = day self.__hour = hour self.__minute = minute self.__second = second self.__millisecond = millisecond self.__monthGeez = constants.Constants().months[self.__month - 1] self.__dayGeez = constants.Constants().dayNumbers[self.__day - 1] self.fixed = self.fixedFromEthiopic(year, month, day) self.moment = self._dateToEpoch(year, month, day, hour, minute, second, millisecond)
def __init__(self): self.evangelists = ["ዮሐንስ", "ማቴዎስ", "ማርቆስ", "ሉቃስ"] self.ameteFida = 5500 self.tinteAbekte = 11 self.tinteMetkih = 19 self.maxMillisecondsSinceEpoch = 8640000000000000.0 self.ethiopicEpoch = 2796 self.unixEpoch = 719163 self.dayMilliSec = 86400000.0 self.hourMilliSec = 3600000 self.minMilliSec = 60000 self.secMilliSec = 1000 self.weekdays = ["ሰኞ", "ማግሰኞ", "ረቡዕ", "ሐሙስ", "አርብ", "ቅዳሜ", "እሁድ"] self.dayNumbers = [ "፩", "፪", "፫", "፬", "፭", "፮", "፯", "፰", "፱", "፲", "፲፩", "፲፪", "፲፫", "፲፬", "፲፭", "፲፮", "፲፯", "፲፰", "፲፱", "፳", "፳፩", "፳፪", "፳፫", "፳፬", "፳፭", "፳፮", "፳፯", "፳፰", "፳፱", "፴" ] self.months = [ "መስከረም", "ጥቅምት", "ኅዳር", "ታኅሳስ", "ጥር", "የካቲት", "መጋቢት", "ሚያዝያ", "ግንቦት", "ሰኔ", "ኃምሌ", "ነሐሴ", "ጷጉሜ" ] util = ut.Util() self.yeeletTewsak = util.getyeeletTewsak() self.yebealTewsak = util.getyebealTewsak() self.geezNumbers = util.getgeezNumbers()
def stop_session(self): status = False util = Util() display = util.getValue("display") if display is not None: logging.info('stopping display %s' % display) logging.debug('ENVS: %s' % os.environ) cmd = "%(vncpath)svncserver -kill %(d)s" % { 'vncpath': Constants.TurboVNC_EXEC_PATH, 'd': display } logging.info('executing cmd %(cmd)s' % {'cmd': cmd}) vnckill = subprocess.Popen(re.split(' ', cmd), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) out, err = vnckill.communicate() if vnckill.returncode != 0: logging.error('display stop failed with error %s' % err) sys.stderr.write(err) else: util.removeDMInfo() logging.info("display stopped successfully") status = True return status
def gen_password(self): status = False util = Util() display = util.getValue("display") logging.info('generating password for display %s' % display) logging.debug('ENVS: %s' % os.environ) cmd = "%(vncpath)svncpasswd -o -display %(d)s" % { 'vncpath': Constants.TurboVNC_EXEC_PATH, 'd': display } logging.info('executing cmd %(cmd)s' % {'cmd': cmd}) vncpassword = subprocess.Popen(re.split(' ', cmd), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) out, err = vncpassword.communicate() if vncpassword.returncode != 0: logging.error('password generation failed with error %s' % err) sys.stderr.write(err) else: logging.info("password generation successful") out = re.split(' ', err)[4] sys.stdout.write(out) sys.stdout.flush() status = True return status
def __holdJob(self): util = Util() session_pid = util.getValue("sessionPid") if session_pid is None: return ltimeout=self.maxtimeout while self.__check_pid(int(session_pid)): sleep(1) timeout = long(self.__readTimeOut()) if timeout == ltimeout: continue if timeout == 0: logging.info('disable session expiry timer') signal.signal(signal.SIGALRM, self.old_handler) signal.alarm(0) else: logging.info('reset session expiry timer from %(f)d to %(t)d' % {'f':ltimeout, 't':timeout}) signal.signal(signal.SIGALRM, self.__expiry_handler) signal.alarm(timeout) ltimeout = timeout signal.signal(signal.SIGALRM, self.old_handler) signal.alarm(0) sleep(2)
def __init__(self, embeddingsDir="", verbose=False): self.util = Util() if embeddingsDir == "": self.embeddingsDir = self.util.embeddingsDir else: self.embeddingsDir = embeddingsDir self.verbose = verbose
def test_instantiate(self): expected_log_message = 'Starting' with self.assertLogs(Util.__name__, level='INFO') as cm: u = Util() self.assertTrue( next((True for line in cm.output if expected_log_message in line), False))
def __init__(self, args): self.logger = ALogger("Graph", True).getLogger() self.util = Util() self.sp = None self.args = args self._build_container()
def getAllAtswamat(self, beal, numOfDays): mebjaHamer = self.getNewewe() all = {} h2 = {} h2["month"] = constants.Constants().months[ util.Util().indexOf(mebjaHamer["month"], constants.Constants().months) + (numOfDays // 30)] values = [beal, h2] if (int(mebjaHamer["date"]) + numOfDays) % 30 == 0: h2["date"] = "30" else: h2["date"] = str((int(mebjaHamer["date"]) + numOfDays) % 30) all = util.Util().getAllAtswamatwDate(values) return all
def __init__(self, year=None): if year == None: localtime = datetime.now(timezone.utc).astimezone( pytz.timezone("Africa/Addis_Ababa")) lst_now = etDateTime.EtDateTime()._parse(str(localtime)) year, month, day = lst_now[0], lst_now[1], lst_now[2] Ethiopia_day = util.Util().gregorianToEthiopic(year, month, day) self.__year = Ethiopia_day[0] else: self.__year = year self.ameteAlem = 5500 + self.__year self.rabeet = self.ameteAlem // 4 self.wenber = util.Util().getWenber(5500, self.__year) self.abekte = self.wenber * 11 % 30 if self.wenber == 0: self.metkih = 30 else: self.metkih = self.wenber * 19 % 30
def getSingleBealOrTsom(self, name): status = self.isMovableHoliday(name) if status: mebajaHamer = self.getNewewe() tewsak = int(constants.Constants().yebealTewsak[name]) values = [ constants.Constants().months[( util.Util().indexOf(mebajaHamer["month"], constants.Constants().months) + (int(mebajaHamer["date"]) + tewsak) // 30)], str((int(mebajaHamer["date"]) + tewsak) % 30) ] else: raise exception.BealNameException( "Holiday is not a movable one. Please provide holidays between ነነዌ and ጾመ ድህነት" ) return util.Util().getSingleBealOrTsomDate(values)
def __init__(self): self.utility = Util() self.x = 100 self.y = 200 self.updateX = 2 self.updateY = 2 self.lives = 3 self.radius = 5 self.thickness = 5
def __init__(self, index_r, index_c, health, color, coordinate, points): self.index_r = index_r self.index_c = index_c self.health = health self.remaining_health = health self.points = points self.color = color self.utility = Util() self.coordinate = coordinate
def to_String(self): ut = util.Util() y = ut._fourDigits(self.__year) m = ut._twoDigits(self.__month) d = ut._twoDigits(self.__day) h = ut._twoDigits(self.__hour) min = ut._twoDigits(self.__minute) sec = ut._twoDigits(self.__second) ms = ut._threeDigits(self.__millisecond) return y + "-" + m + "-" + d + " " + h + ":" + min + ":" + sec + "." + ms
def __init__(self, working_dir): self.class_list = set() self.class_dict = {} self.links_count = {} self.working_dir = working_dir + "/~results" if not os.path.isdir(self.working_dir): os.mkdir(self.working_dir) self.util = Util( working_dir) # used for save and load the analysis performed
def main(): pygame.init() utility = Util() DISPLAYSURF = pygame.display.set_mode( (utility.getScreenWidth(), utility.getScreenHeight())) DISPLAYSURF.fill(utility.getColor("white")) pygame.display.set_caption('Demo!') load_main_screen(utility, DISPLAYSURF) play_game(utility, DISPLAYSURF)
def get_tokens(host, paras): util = Util(host) login_list = util.getChannelLoginIds(paras.channel) res = util.token_threading(paras.pool, util.get_token_by_thread, login_list) data = [] for res_data in res: data.append(res_data.get()) file_path = os.path.join('../token/', host.name +'8.csv' ) util.to_csv(file_path, data)
def mesResolucao(self, Detalhe): mes_pattern = re.compile( u'DE\s*(?P<mes>JANEIRO|FEVEREIRO|MARÇO|ABRIL|MAIO|JUNHO|JULHO|AGOSTO|SETEMBRO|OUTUBRO|NOVEMBRO|DEZEMBRO)\s*DE' ) mes = mes_pattern.search(Detalhe) if (mes): util = Util() vlr = mes.group('mes') vlr = util.retornaMes(vlr) else: vlr = '00' return vlr
def today(cls): localtime = str(datetime.now(timezone.utc).astimezone(pytz.timezone("Africa/Addis_Ababa"))) lst_now = Et.EtDateTime().parse(localtime) year = lst_now[0] month = lst_now[1] day = lst_now[2] hour = lst_now[3] minute = lst_now[4] second = lst_now[5] millisecond = lst_now[6] res = util.Util().gregorianToEthiopic(year, month, day) return ETC(res[0], res[1], res[2])
def select_features(self): feature_selection = FeatureSelection() # select features using xgboost selected_features = feature_selection.selected_features_by_xgboost( self.normalize()) selected_features_index = Util().selected_features_for_xgboost( selected_features) selected_features_by_xgboost = self.data.ix[:, selected_features_index] features_with_target = pd.concat( [selected_features_by_xgboost, self.data['target']], axis=1) return features_with_target
def __init__(self, args, sigma_l=0.4, sigma_iou=0.5, sigma_min=4, sigma_keep=30, sigma_h=0.9, back_thre=0.6, use_sot=7): self.sigma_l = sigma_l self.sigma_iou = sigma_iou self.sigma_min = sigma_min self.sigma_keep = sigma_keep self.sigma_h = sigma_h self.back_thre = back_thre self.use_sot = use_sot self.args = args self.util = Util() self.sot_tracker = self.build_sot() print('Tracker initialization completed...')
def start_app(self, cmd, args=None, envs=None, cwd=None, display=None): sessionmgr = TurboVNCSessionManager() configmgr = ConfigurationProvider() # Get the allocated GPU resource resource = self.__getRes() logging.info("GPU resource id =%(res)s" % {'res': resource}) # Validate X access as the first thing for OpenGL apps if self.__check_X_access(resource) != 0: return False # Start a new TurboVNC server if required if display is None: display = sessionmgr.start_session() if display is None: return False # Update the process envs self.__updateEnvs(envs) # Set the DISPLAY environment os.environ['DISPLAY'] = display envs = os.environ.copy() if cwd is None: cwd = configmgr.get_config("PBS_JOBDIR") if resource is not None: cmd = "%(vglpath)svglrun -d %(d)s -sp %(cmd)s" % { 'vglpath': Constants.VGL_EXEC_PATH, 'd': resource, 'cmd': cmd } if args is not None: cmd = '%(c)s %(a)s' % {'c': cmd, 'a': args} # Start the application on a given display {use VGL for OpenGL} logging.info("starting application exec=%(cmd)s envs=%(envs)s cwd=%(cwd)s display=%(d)s" \ % {'cmd':cmd, 'envs':envs, 'cwd':cwd, 'd':display}) appname = configmgr.get_config('PAS_APPLICATION') app = subprocess.Popen(re.split(' ', cmd), env=envs, cwd=cwd, shell=False, \ stdout=open('%s.STDOUT'%appname, 'w'), \ stderr=open('%s.STDERR'%appname, 'w'), close_fds=True) util = Util() util.update("appPid", app.pid) return True
def startExecution(self,bmcTypeCmdExecution,bmcPluginName): bmcLog = customLog() bmcUtil = Util() bmcJsonRPCServer = JsonRPCServer() if bmcTypeCmdExecution == "RPC": #starte RPC Server Method here bmcLog.log("Executing RPC server to handle json rpc data") bmcJsonRPCServer.callJSONRPCServer(bmcPluginName) if bmcTypeCmdExecution == "startApp": bmcLog.log("\n Executing Start Application Command") bmcUtil.runPlugin(bmcPluginName) if bmcTypeCmdExecution == "stdout": bmcLog.log("\n Executing stdout application Command") bmcUtil.runPlugin(bmcPluginName)
def main(): util = Util() if util.options['run']: if util.options['config']: print("Enter in configuration mode") frontend = Frontend(config_mode=True, util_param=util) elif util.options['scan_roms']: print("Scan new roms") # util.scan_roms() frontend = Frontend(config_mode=False, util_param=util) else: frontend = Frontend(config_mode=False, util_param=util) frontend.save_current_mode() if util.options['shutdown_on_exit']: os.system(util.options['shutdown_command'])
def application(self,request): # Dispatcher is dictionary {<method_name>: callable} bmcUtil = Util() bmcListOfMethods = {} bmcListOfMethod = bmcUtil.readLocalAppVariableFile("BMC_JSONRPCCALL_METHODS") bmcListOfMethod = bmcUtil.removeDoubleQuotas(bmcListOfMethod) bmcListOfMethods = bmcListOfMethod.split(",") for methodName in bmcListOfMethods: dispatcher[methodName] = lambda methodName: methodName #dispatcher["event"] = lambda a: a response = JSONRPCResponseManager.handle( request.data, dispatcher) print response.json bmcUtil.writeRPCCallDataTOFile(response.json) return Response(response.json, mimetype='application/json')
def __update(self, vncoutput, geometry): status = False for token in vncoutput.split("\n"): m = re.search('Desktop', token, re.IGNORECASE) if m: display = re.search('\d+', re.split(':', token)[-1]).group() status = True if not status: return status cmd = ['ps', '-eaf'] ps = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) out, err = ps.communicate() logging.info('display %s' % display) status = False for item in out.split("\n"): m = re.search('Xvnc', item, re.IGNORECASE) if m: str = "%(h)s:%(d)s" % {'h': socket.gethostname(), 'd': display} m = re.search(str, item, re.IGNORECASE) if m: entries = re.split('\s+', item.strip()) pid = entries[1] idx = 0 for entry in entries: if entry == "-rfbport": port = entries[idx + 1] status = True break idx += 1 break if status: output = "display=:%(d)s\ngeometry=%(geo)s\nhost=%(host)s\nport=%(port)s\nsessionPid=%(pid)s\n" \ % {'d':display, 'geo':geometry, 'host':socket.gethostname(), 'port':port, 'pid':pid} logging.info('display server started successfully: %s' % output) util = Util() util.createDMInfo(output) else: logging.error('failed to update session information') sys.stderr.write('failed to update session information') return status