Пример #1
0
import json
from config_reader import config as cr
import os

directory_path = cr.get('Results', 'directory_path')

def write_data_to_file(filename, json_data):
    f = open(os.path.join(directory_path, filename), "w")
    f.write(json.dumps(json_data))
    f.close()
Пример #2
0
import methods, file_writer
from config_reader import config as cr
import datetime
from telegram_notifications import send_telegram_message as stm
from logger import logger

stm("TestRail Stats Collector script started ▶")
start_time = datetime.datetime.now()

try:
    logger.info('Process Started')
    print("{}: Started logger".format(datetime.datetime.now()))

    # getting project name from config
    project_name = cr.get('TestRail Filters', 'project_name')
    print("{}: Finished reading config file".format(datetime.datetime.now()))
    logger.info('Finished reading config file')

    users = methods.get_users()
    file_writer.write_data_to_file("users.json", users)

    projects = methods.get_projects()
    file_writer.write_data_to_file("projects.json", projects)

    case_types = methods.get_case_types()
    file_writer.write_data_to_file("case_types.json", case_types)

    statuses = methods.get_statuses()
    file_writer.write_data_to_file("statuses.json", statuses)

    priorities = methods.get_priorities()
Пример #3
0
import file_writer
from config_reader import config as cr
from telegram_notifications import send_telegram_message as stm
from logger import logger
import datetime

stm("Jira worklogs script started ▶")
start_time = datetime.datetime.now()

try:
    # logging
    logger.info('Process Started')
    print('Started logging')

    # Get data from config file
    username = cr.get('Auth', 'username')
    password = cr.get('Auth', 'password')
    jira_url = cr.get('Server', 'jira_url')
    jql_query = cr.get('Jira', 'jql_query')
    max_results = cr.get('Jira', 'max_results')
    file_name = cr.get('Results', 'file_name')
    print('Finished reading config file')

    options = {
        'server': jira_url,
        'async': True}

    print('Establishing connection to Jira')
    jira = JIRA(options, basic_auth=(username, password))

    # Get all projects viewable by anonymous users.
Пример #4
0
import logging
import argparse
from config_reader import config as cr

# adding command-line arguments
parser = argparse.ArgumentParser()
parser.add_argument("-l",
                    "--log",
                    help="you can pass --log (-l) argument: INFO/WARN/DEBUG",
                    type=str)
# parse command-line arguments
args = parser.parse_args()

log_level = ""
#read config
log_level = cr.get('Dev', 'log_level')

# if log_level is null
if args.log is not None and log_level is None:
    log_level = args.log
if args.log is None and log_level is not None:
    log_level = log_level
else:
    log_level = "INFO"

logger = logging.getLogger()
logger.setLevel(log_level)  # or whatever
handler = logging.FileHandler('system_log.log', 'a+', 'utf-8')
formatter = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
Пример #5
0
import requests
from config_reader import config as cr
import base64

# Get data from config file
username = cr.get('Auth', 'username')
# password = cr.get('Auth', 'password')
api_key = cr.get('Auth', 'api_key')
testrail_url = cr.get('Server', 'testrail_url')

# Encode username and password to base64 string
base64_auth_string = username + ":" + api_key
base64_auth = base64.b64encode(bytes(base64_auth_string, "utf-8"))
base64_auth = bytes(base64_auth).decode("utf-8")

# Auth
headers = {
    'content-type': "application/json",
    'authorization': "Basic {}".format(base64_auth)
}


def get_users():
    get_users_endpoint = {"/api/v2/get_users": ""}
    response = requests.request("GET",
                                testrail_url,
                                headers=headers,
                                params=get_users_endpoint)
    return response.json()

Пример #6
0
import datetime
import telegram
from config_reader import config as cr

# Get data from config file
bot_token = cr.get('Telegram', 'bot_token')
chat_id = cr.get('Telegram', 'chat_id')

bot = telegram.Bot(token=bot_token)


def send_telegram_message(msg_text):
    bot.send_message(chat_id=chat_id,
                     text="*{:%Y-%m-%d %H:%M}:* `{}`".format(
                         datetime.datetime.now(), msg_text),
                     parse_mode=telegram.ParseMode.MARKDOWN)