示例#1
0
def get_name_by_date(modality, dest) -> str:
    """Save the recorded log into /Data/Date/<Modality_name>/Raw

    Args:
        modality (str): The log data source
        dest(str): The folder to save the data
    Returns:
        str: The absolute path where each recording is saved
    """
    current_path = os.path.abspath(os.getcwd())
    os.chdir('..')
    current_path = (os.path.abspath(os.curdir))
    current_path = os.path.join(current_path, 'Data', ut.get_date())

    if modality == 'Chair':
        chair_path = os.path.join(current_path, modality, dest)
        return chair_path

    elif modality == 'Mouse':
        mouse_path = os.path.join(current_path, modality, dest)
        return mouse_path

    elif modality == 'Keyboard':
        keyboard_path = os.path.join(current_path, modality, dest)
        return keyboard_path
示例#2
0
def get_dirs_by_date(modality):
    current_path = os.path.abspath(os.getcwd())
    os.chdir('..')
    current_path = (os.path.abspath(os.curdir))
    os.chdir('./Data')
    current_path = (os.path.abspath(os.curdir))
    current_path = os.path.join(current_path, ut.get_date(), modality)
    raw_data_path = os.path.join(current_path, 'Raw')
    csv_data_path = os.path.join(current_path, 'CSV')
    edited_logs_path = os.path.join(current_path, 'Edited_logs')
    features_path = os.path.join(current_path, 'Features')

    return raw_data_path, csv_data_path, edited_logs_path, features_path
示例#3
0
def initialize_dirs_by_date():
    """Create the appropriate directories in order to save
       and process the collected data
    """
    current_path = os.path.abspath(os.getcwd())
    os.chdir('..')
    current_path = (os.path.abspath(os.curdir))  #Parent folder
    current_path = os.path.join(current_path, 'Data')
    ut.create_subdirs([current_path])

    #Create the date folder
    current_path = os.path.join(current_path, ut.get_date())
    ut.create_subdirs([current_path])

    #Create the feature folder
    features = os.path.join(current_path, 'Features')
    ut.create_subdirs([features])

    #Create mouse log folder
    mouse = os.path.join(current_path, 'Mouse')
    ut.create_subdirs([mouse])
    #Create mouse subfolders
    names = ut.concat_names(mouse)
    ut.create_subdirs(names)

    #Create keyboard log  folder
    keyboard = os.path.join(current_path, 'Keyboard')
    ut.create_subdirs([keyboard])
    #Create keyboard subfolders
    names = ut.concat_names(keyboard)
    ut.create_subdirs(names)

    #Create the chair log folder
    chair = os.path.join(current_path, 'Chair')
    ut.create_subdirs([chair])
    #Create chair subfolders
    names = ut.concat_names(chair)
    ut.create_subdirs(names)

    #Create webcam log folder
    webcam = os.path.join(current_path, 'Webcam')
    ut.create_subdirs([webcam])
示例#4
0
# -*- coding: utf-8 -*-
from threading import Timer
from pynput import keyboard
import logging
import os
import sys

sys.path.insert(
    0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))
from Functions import utils as ut

if __name__ == '__main__':
    rec_file = ''.join((ut.get_date(), '_', ut.get_time(), '.txt'))
    raw_data = ut.get_name('Keyboard', 'Raw')
    rec_file = os.path.join(raw_data, rec_file)
    logging.basicConfig(filename=rec_file,
                        level=logging.DEBUG,
                        format="%(asctime)s    %(message)s")

    try:
        with keyboard.Listener(on_press=ut.on_press_keys) as listener:
            Timer(100, listener.stop).start()
            listener.join()
    except KeyboardInterrupt as err:
        print(err)
        sys.exit(0)

    ut.insert_last_timestamp(rec_file)
    print('Exiting key logger...')
示例#5
0
# -*- coding: utf-8 -*-
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(
    os.path.realpath(__file__)), "../"))

from Functions import utils as ut

if __name__ == '__main__':

    ut.initialize_dirs()
    rec_file = ut.get_date()+'.txt'
    raw_data = ut.get_name('Chair')
    rec_file = os.path.join(raw_data,rec_file)
    ut.record_chair(rec_file)
# -*- coding: utf-8 -*-
from threading import Timer
from pynput.mouse import Listener
import logging
import sys
import os
sys.path.insert(
    0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))

from Functions import utils as ut

if __name__ == '__main__':

    rec_file = 'mouse_' + ut.get_date() + '.txt'
    raw_data = ut.get_name('Mouse')
    rec_file = os.path.join(raw_data, rec_file)
    logging.basicConfig(filename=rec_file,
                        level=logging.DEBUG,
                        format="%(asctime)s    %(message)s")

    try:
        with Listener(on_move=ut.on_move,
                      on_click=ut.on_click,
                      on_scroll=ut.on_scroll) as listener:
            Timer(60, listener.stop).start()
            listener.join()
    except KeyboardInterrupt as err:
        print(err)
        sys.exit(0)