import sys import logging import configparser import getopt import os import atexit from alkivi.logger import Logger from scriptlock import Lock from freshdesk.api import API from models import Phonebook, IPBXBinder from helpers import need_sync, format_contact, set_logger # Define the global logger logger = Logger(min_log_level_to_mail=logging.WARNING, min_log_level_to_save=logging.DEBUG, min_log_level_to_print=logging.INFO, emails=['*****@*****.**']) set_logger(logger) LOCK = Lock() atexit.register(LOCK.cleanup) ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) DRY = False def usage(): """Small helper to use when --help is pass """ print('Usage: ' + sys.argv[0] + ' -h -d -your own options' + '\n') print('-h --help Display help')
#!/usr/bin/env python import os import time import logging import click from slackclient import SlackClient from sqlalchemy.orm import sessionmaker from alkivi.logger import Logger from louisebot.config import config from louisebot.db import Base, engine, DBSession, User logger = Logger(min_log_level_to_mail=None, min_log_level_to_save=logging.INFO, min_log_level_to_print=logging.INFO) @click.group() @click.option('--debug/--no-debug', default=False) def cli(debug): logger.info('Starting manager.py') if debug: logger.set_min_level_to_print(logging.DEBUG) logger.set_min_level_to_save(logging.DEBUG) logger.debug('Debug mode activated') @cli.command()
#!/usr/bin/env python # -*-coding:utf-8 -* import logging import click from alkivi.logger import Logger from alkivi.odoo import client as odoo # Define the global logger logger = Logger(min_log_level_to_mail=None, min_log_level_to_save=logging.DEBUG, min_log_level_to_print=logging.DEBUG) @click.command() @click.option('--endpoint', prompt='Odoo conf to use :', default='sqq-recette', help='Section of ~/.odoo.conf to use') @click.option('--dry', prompt='Activate dry mode ?', default=False, is_flag=True, help='Do not commit shit') def fix_category_print(endpoint, dry): """Fix Odoo BarCode.""" odoo_client = odoo.Client(logger=logger, endpoint=endpoint) search_args = [('has_theoritical_cost_different', '=', True)] product_ids = odoo_client.search('product.template', search_args)
import os import yaml import atexit import click import logging import ovh from configparser import ConfigParser from ovh.exceptions import ResourceNotFoundError, BadParametersError from scriptlock import Lock from alkivi.logger import Logger # Define the global logger logger = Logger(min_log_level_to_mail=logging.CRITICAL, min_log_level_to_save=logging.DEBUG, min_log_level_to_print=logging.INFO, min_log_level_to_syslog=None) # Optional lock file LOCK = Lock() atexit.register(LOCK.cleanup) DEFAULT_PATH = '/home/backup-telephony' def get_config(): """Read configuration from script path and load it.""" basedir = os.path.abspath(os.path.dirname(__file__)) config_file = os.path.join(basedir, 'backup.conf') config = ConfigParser() if os.path.isfile(config_file):