def setUpClass(cls): cls.poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False) content = load_yaml_file(os.getcwd() + '/config/cashier.yml') user_info = content.get('ShopManagerInfo') cls.merchant_code = user_info['merchantcode'] cls.user_code = user_info['usercode'] cls.password = user_info['password']
def convert_word(tweet): '''Convert word to corresponding term.''' # load from yaml, get dictionary synonym_data = util.load_yaml_file(synonyms_file) # Replace word for synonym in synonym_data.keys(): tweet = tweet.replace(synonym, ' ' + synonym_data[synonym] + ' ') return tweet
def convert_emoticon(tweet): '''Convert emoticon to corresponding term.''' # load from yaml, get dictionary emoticon_data = util.load_yaml_file(emoticons_file) # Replace emoticons for emoticon in emoticon_data.keys(): tweet = tweet.replace(emoticon, ' ' + emoticon_data[emoticon] + ' ') return tweet
def remove_stop_words(tweet): '''Remove stop words.''' stop_words = util.load_yaml_file(stop_words_file) tweet_words = tweet.split(' ') new_tweet = [] for tweet_word in tweet_words: if tweet_word not in stop_words: new_tweet.append(tweet_word) return ' '.join(new_tweet)
def load_config(self): try: self.config = util.load_yaml_file(self.config_file) except: if self.config == {}: logger.critical("Issue Loading config: %s Exiting", self.config_file) exit() else: logger.critical( "Issue reloading config: %s Keeping current settings", self.config_file)
def convert_negation(tweet_text): '''Count negation word. If odd, it is a negation tweet_text, return True, otherwise not.''' negation_words = util.load_yaml_file(negation_words_file) num_negation_word = 0 new_tweet_text = [] tweet_text_words = tweet_text.split(' ') for tweet_word in tweet_text_words: if tweet_word in negation_words: num_negation_word += 1 else: new_tweet_text.append(tweet_word) if num_negation_word % 2 == 1: return True,' '.join(new_tweet_text) else: return False,' '.join(new_tweet_text)
def setUpClass(cls): # super(MerchantActivateAndLogin, cls).setUpClass() caps = {} caps["platformName"] = "Android" caps["platformVersion"] = "6.0" caps["deviceName"] = "48decad2" caps["appActivity"] = "com.ziyuanpai.caibao.MainActivity" caps["appPackage"] = "com.ziyuanpai.caibao" cls.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps) cls.driver.implicitly_wait(5) content = util.load_yaml_file(os.getcwd() + '/config/merchant_notVIP.yml') merchant_info = content.get('MerchantInfo') cls.merchant_code = merchant_info['merchant_code'] cls.password = merchant_info['password'] merchant_activate(cls.driver, cls.merchant_code)
logging.info("Running %s", p._name) client.send(p.encode()) logging.debug("Waiting for ack") message = client.recv() logging.info("Recieved ack") time.sleep(self.config['client']['sleep']/1000) self.check_config() except zmq.error.ZMQError as e: logger.critical("ZMQError, Exiting: %s", e) exit() if __name__ == '__main__': if zmq.zmq_version_info() < (4,0): raise RuntimeError("Security is not supported in libzmq version < 4.0. libzmq version {0}".format(zmq.zmq_version())) config = util.load_yaml_file(util.config.CLIENT["config"]) util.init_logging(**config['logging']) daemon = Client(config['pid_file'], config_file=util.config.CLIENT["config"]) daemon.run() if len(sys.argv) == 2: if 'start' == sys.argv[1]: daemon.start() elif 'stop' == sys.argv[1]: daemon.stop() elif 'restart' == sys.argv[1]: daemon.restart() else: print "Unknown command" sys.exit(2) sys.exit(0) else:
self.load_plugins() logger.info("Starting reciever.") while True: msg = server.recv() self.handle_msg(msg) server.send("ack") auth.stop() if __name__ == '__main__': if zmq.zmq_version_info() < (4,0): raise RuntimeError("Security is not supported in libzmq version < 4.0. libzmq version {0}".format(zmq.zmq_version())) config = util.load_yaml_file(util.config.SERVER["config"]) util.init_logging(**config['logging']) daemon = Server(config['pid_file'], config_file=util.config.SERVER["config"]) logger.info("Started Server") daemon.run() if len(sys.argv) == 2: if 'start' == sys.argv[1]: daemon.start() elif 'stop' == sys.argv[1]: daemon.stop() elif 'restart' == sys.argv[1]: daemon.restart() else: print "Unknown command" sys.exit(2) sys.exit(0)