Example #1
0
def pre_init():
    config: configparser.ConfigParser
    version = "1.2.1"
    build = "4"

    if logger.logger_init():
        logging.info("log was cleared successful")

    config = utils.config_init()
    logger.logger_config_init(config)
    ad_module_init(config)
    distort_init(config)
    utils.whitelist_init()
    interlayer.translate_init()
    utils.list_of_langs()
    locales.locales_check_integrity(config)
    if locales.locale_data.get("version") != version:
        logging.warning(
            "Polyglot and locale versions doesn't match! This can cause the bot to malfunction."
            "\nPlease, try to check updates for bot or locales file.")
    logging.info("###POLYGLOT {} build {} HAS BEEN STARTED###".format(
        version, build))
"""
Removes old versions of Lambda functions.
"""
import logging
import sys
from pathlib import Path
file = Path(__file__).resolve()
sys.path.append(str(file.parent))
import logger
import boto3

# Initialize log
logger.logger_init()
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
logger.propagate = False

try:
    CLIENT = boto3.client('lambda', region_name='eu-west-1')
except Exception as exception:
    logger.error(str(exception), exc_info=True)

# Number of versions to keep
KEEP_LAST = 10


def clean_lambda_versions(event, context):
    """
    List all Lambda functions and call the delete_version function.
    Check if the paginator token exist that's included if more results are available.
Example #3
0
 def __init__(self):
     self.game_state = 1  # 1 表示游戏没有结束,0表示结束
     self.logger = logger_init()
     self.camera = Camera(self.logger)
     self.robot = Robot()
     self.board = None
Example #4
0
def main():
    _config_file = "tcp_server.conf"
    _config_section = "server"
    _logger_fname = ""
    _server_host = None
    _server_port = None
    _max_block_size = 1024

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hc:", [
            "help",
            "config=",
        ])
    except:
        print("Undefined option(s).\nUsage: python " + sys.argv[0] +
              " {-c config_file.conf| --config=config_file.conf}")
        sys.exit(1)

    for oo, a in opts:
        if oo in ("-h", "--help"):
            print("Undefined option(s).\nUsage: python " + sys.argv[0] +
                  " {-c config_file.conf| --config=config_file.conf}")
            sys.exit(0)

        elif oo in ("-c", "--config"):
            _config_file = a
        else:
            print("Undefined option(s).\nUsage: python " + sys.argv[0] +
                  " [-c | --config=]config_file ")
            sys.exit(1)

    try:
        _logger_fname = get_setting(_config_file, _config_section,
                                    "logger_file")
    except configparser.NoSectionError as e:
        print("section not found: ", str(e))
    except configparser.NoOptionError as e:
        print("option not found: ", str(e))
    finally:
        pass

    try:
        _server_host = get_setting(_config_file, _config_section,
                                   "server_host")
    except configparser.NoSectionError as e:
        print("section not found: ", str(e))
    except configparser.NoOptionError as e:
        print("option not found: ", str(e))
    finally:
        pass

    try:
        _server_port = get_setting(_config_file, _config_section,
                                   "server_port")
    except configparser.NoSectionError as e:
        print("section not found: ", str(e))
    except configparser.NoOptionError as e:
        print("option not found: ", str(e))
    finally:
        pass

    try:
        _max_block_size = int(
            get_setting(_config_file, _config_section, "max_block_size"))
    except configparser.NoSectionError as e:
        print("section not found: ", str(e))
    except configparser.NoOptionError as e:
        print("option not found: ", str(e))
    finally:
        pass

    logger_fname = _logger_fname
    q_log_listener, global_vars.logger_queue = logger_init(logger_fname)

    global_vars.main_logger = logging

    tcp_server = TCPserver(
        server_host=_server_host,
        server_port=_server_port,
        max_block_size=_max_block_size,
    )

    tcp_server.run_server()
import gtk
from logger import logger_init
from settings import config
logger = logger_init()
settings = config()
class prefs:
	
	def destroy(self,widget):        
		self.pref_win.hide()

	def Radio_Call_Back(self,widget,data=None):		
		
		test = (("OFF","ON")[widget.get_active()])
		Toggled = data +" " + test
		if Toggled == "Always_show ON":
			logger.debug("DEBUG Always show an icon")
			settings.write_settings_int("show_icon","1")	
			return
		elif Toggled == "show_charging_discharging ON":
			logger.debug("DEBUG only show when battery is charging or discharing")
			settings.write_settings_int("show_icon","3")
			return
		elif Toggled == "Show_discharging_only ON":
			logger.debug("DEBUG Show an icon when discharging")
			settings.write_settings_int("show_icon","2")
			return
            
	def okay_button_clicked(self,widget,data=None):
		self.pref_win.hide()
		print "OKAY"
	
  return model

def create_dataframe_from_ESjson(elastic_docs):
    docs = pd.DataFrame()
    for num, doc in enumerate(elastic_docs):
        source_data = doc["_source"]
        _id = doc["_id"]
        doc_data = pd.Series(source_data, name = _id)
        docs = docs.append(doc_data)

    logger.info("Python - Remove meta data column in Dataframe")
    docs = docs[['SEX', 'LEN', 'DIA', 'HEI', 'W1', 'W2', 'W3', 'W4', 'RIN']]
    docs = docs.reset_index(drop=True)
    return docs

logger = logger_init()

# configure elasticsearch
config = {
    "host": "127.0.0.1",
    "port": "9200" 
}

logger.info("Elasticsearch - Creating connexion")
logger.info("Elasticsearch - {}".format(config))
es = Elasticsearch([config,], timeout=300)

# ['SEX', 'LEN', 'DIA', 'HEI', 'W1', 'W2', 'W3', 'W4', 'RIN']
request_body = {
    "settings" : {
        "number_of_shards": 5,
Example #7
0
def run(cmd, logger, outfile = None) :
	if outfile is not None :
		fH = file(outfile, 'w')
		proc = Popen(split(cmd), stdout=fH, stderr=PIPE)
		proc_stderr = proc.communicate()[1]
	else :
		proc = Popen(split(cmd), stdout=PIPE, stderr=PIPE)
		proc_stdout, proc_stderr = proc.communicate()
	if proc.returncode != 0 :
		logger.error(proc_stderr)
		exit()
	else :
		if proc_stderr != "" :
			logger.info(proc_stderr)

if __name__ == "__main__" :
	parser = ArgumentParser(description="Call BWA/NovoAlign to map reads to a given reference")
	parser.add_argument("-config", metavar="FILE", dest="config_file", help="a configuration file with paths to reference, fastq files.")
	parser.add_argument("-mapper_log", metavar="FILE", dest="mapper_log_file", help="log file generated by any mapper programs")
	parser.add_argument("--debug", action="store_true", dest="debug", help="for debug purpose, more information is spit out")

	args = parser.parse_args()

	# initiate logger #
	logger = logger_init(args.mapper_log_file)

	check_file_existence(logger, args.debug, args.config_file)

	# parse the config file #
	parse_config(args.config_file, logger, args.debug)
Example #8
0
    broccoli.broccoli
    ~~~~~~~~~~~~~

    This project aims to ease the computation of certain problems by introducing
    tools parallelization and multiprocessing.

    :copyright: 2015 Manuel Martins, see AUTHORS for more details
    :license: Apache 2.0, see LICENSE for more details
"""

import argparse
from logger import initialize as logger_init
import json_parser
from job import Job
import logging

if __name__ == '__main__':
    args_parser = argparse.ArgumentParser(
        description='Main entry point for Broccoli Module. Usage: python -m broccoli -i <input.json>'
    )
    args_parser.add_argument('-v', '--verbose', help='increase output verbosity', action='store_true',
                             required=False)
    args_parser.add_argument('-i', '--input', help='input json file / string', action='store',
                             dest='input', required=True)
    logging.info('Broccoli - Initializing...')
    args = args_parser.parse_args()
    json = json_parser.parse(args.input)
    logger_init(json, args.verbose)
    job = Job(json)
    job.start()
Example #9
0
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Helper methods
# Author: Satheesh Rajendran<*****@*****.**>

import commands
import os
import re
import sys

from logger import logger_init

LOG_PATH = os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir)))

logger = logger_init(filepath=LOG_PATH).getlogger()


def runcmd(cmd, ignore_status=False, err_str="", info_str="", debug_str=""):
    """
    Running command and get the results

    :param cmd: Command to run
    :param ignore_status: Whether to exit program on failure
    :param err_str: String to be printed in case of command error
    :param info_str: Info string to be printed, default None
    :param debug_str: Debug string to be printed, default None
    :param log: log handle

    :return: Status and output of the command
    """