Beispiel #1
0
 def test_delete_folder(self, rm_mock):
     rm_mock.return_value = True
     path = '/home/sheetal/dm_dir'
     result = functions.delete_folder(path)
     self.assertEqual(result, None)
    print('5. Посмотреть только папки')
    print('6. Посмотреть только файлы')
    print('7. Просмотр информации об операционной системе')
    print('8. Создатель программы')
    print('9. Играть в викторину')
    print('10. Мой банковский счет')
    print('11. Смена рабочей директории')
    print('12. Информация о текущей сессии')
    print('13. Сохранить содержимое рабочей директории в файл')
    print('14. Выход')

    choice = input('Выберите пункт меню: ')
    if choice == '1':
        fn.create_folder()
    elif choice == '2':
        fn.delete_folder()
    elif choice == '3':
        fn.copy_folder()
    elif choice == '4':
        fn.return_list_work_dir()
    elif choice == '5':
        fn.return_list_work_dir(1)
    elif choice == '6':
        fn.return_list_work_dir(2)
    elif choice == '7':
        print('Информация об перационной системе: ', PROGRAM_INFO['OS'])
    elif choice == '8':
        print('Автор программы: ', PROGRAM_INFO['author'])
    elif choice == '9':
        vk.start_victory()
    elif choice == '10':
def process_test_run_request(ch, method, properties, body):
    """
    rabbitmq consumer callback function.
    """
    logger.info('{} Inside: process_test_run_request'.format(TEST_RUN_LOG_ID))
    logger.debug('{} process_test_run_request: parameters - '
                 '{}, {}, {}, {}'.format(TEST_RUN_LOG_ID, ch, method,
                                         properties, body))
    print("Message Received {}".format(body))
    print("started processing message.")
    try:
        msg_dict = json.loads(body.decode())
    except Exception as e:
        logger.debug("{} invalid message. ".format(TEST_RUN_LOG_ID))
        logger.exception("{} {}".format(TEST_RUN_LOG_ID, e))
        ch.basic_ack(delivery_tag=method.delivery_tag)
        print("Done processing message.")
        return True
    try:

        # Start Test execution.
        #touch("/src/sheetal_123")
        #time.sleep(60)
        start_date = datetime.utcnow()

        dest_path = "/src/test_scripts"
        src_path = "/mnt/test_run_" + msg_dict['id']
        delete_folder(dest_path)
        copy(src_path, dest_path)

        result = test_runner_for_python(dest_path)
        end_date = datetime.utcnow()
        update_data = {
            'started_at': start_date,
            'finished_at': end_date,
            'environment': 'test_env_1',
            "status": "Complete",
            "logs": result
        }
        db = DBSession()
        #db.create_entry()
        db.update_new_query(3, update_data)
        db.session_close()
        # Removing the message from queue.
        ch.basic_ack(delivery_tag=method.delivery_tag)
    except Exception as e:
        logger.info('{} Exit: process_test_run_request {}'.format(
            TEST_RUN_LOG_ID, e))
        # Checking for custom attribute.
        #if hasattr(e, 'message'):
        #    err_msg = "{}".format(e.message)
        #else:
        #    err_msg = "{}".format(e)

        # Printing stacktrace.
        #logger.critical("{} Exception occured in rabbitmq consumer callback."
        #                .format(TEST_RUN_LOG_ID))
        #logger.exception("{} {}".format(TEST_RUN_LOG_ID, err_msg))

        # Logging more information about exception.
        #logger.critical("{} Exception {} occured ".format(TEST_RUN_LOG_ID, type(e).__name__))
        #if type(e).__name__ == "APIException":
        #    logger.critical("{} APIException received message {}"
        #                    .format(TEST_RUN_LOG_ID, e.received_message.text))
        #    logger.critical("{} APIException custom message {}"
        #                    .format(TEST_RUN_LOG_ID, e.custom_message))

        # Removing message from queue.
        ch.basic_ack(delivery_tag=method.delivery_tag)
    logger.info('{} Exit: process_test_run_request'.format(TEST_RUN_LOG_ID))
    print("Done processing of test run message.")
    return True
Beispiel #4
0
folders.

Ex:
python get_import_data.py mypics 0.9
'''

import os, sys
import numpy as np
from PIL import Image
from resizeimage import resizeimage
import functions as funcs

input_dir = sys.argv[1]
image_dir = 'images'

funcs.delete_folder(image_dir)
train_perc = float(sys.argv[2])

for class_name in os.listdir(input_dir):
	for fname in os.listdir(input_dir + '/' + class_name):
		extension = fname[-3:].lower()
		if extension != 'png' and extension != 'jpg' and extension != 'jpeg':
			continue
			
		split = ''
		
		# uses train_perc as a probability, e.g. 0.9 split is seen as a 0.9 probability
		# to place the item into the train folder
		choice = np.random.choice([True, False], 1, p=[train_perc, 1 - train_perc])[0]
		if choice:
			split = 'train'
Beispiel #5
0
    outname=sys.argv[2]
    if len(sys.argv) > 3:
        base_format=sys.argv[3]
    else:
        base_format='GTFS'
    workspace=__root__.real_path() +'data/'
    for coverage in list_coverage:
        charge_from_ODS(workspace,coverage,base_format)
    if base_format=='GTFS':
        from GTFS_merger import *
    elif base_format=='NTFS':
        from NTFS_merger import *
    else:
        print('ERROR TO DETERMINE FORMAT')

    merger(files,list_coverage, workspace)
    new_stop_file=delete_duplicate_stops(workspace+'new/stops.txt')
    shutil.move(new_stop_file,workspace+'new/stops.txt')
    try:
        zip(workspace+outname+'.zip',workspace+'new/')
    except Exception as e:
        print('ERREUR LORS DU ZIPPAGE DE '+workspace+outname+'.zip')
    for coverage in list_coverage:
        delete_folder(workspace+coverage+'/')
    delete_folder(workspace+'new/')
    if move_to_ftp:
        ## import private configuration for FTP (host,login,password, repository)
        send_ftp(host,login,password, workspace+outname+'.zip', ODS_repository)
        os.remove(workspace+outname+'.zip')