<commit_before>#! /usr/bin/env python

import os, sys, subprocess, time, shutil, Image, threading, random
import urllib2
from constants import *
from packages.rmconfig import configtool

ROOT_PATH = "/home/pi/raspmedia/"
MEDIA_PATH = ROOT_PATH + "Raspberry/media"
USB_PATH = "/media/usb0/"
USB_MEDIA_PATH = USB_PATH + 'raspmedia'

def UsbDrivePresent():
    proc = subprocess.Popen(["ls /dev | grep 'sda'"], stdout=subprocess.PIPE, shell=True)
    (out, err) = proc.communicate()
    if 'sda' in out:
        return True
    else:
        return False

def RaspMediaFilesPresent():
    # check if usb contains kiosk directory
    if os.path.isdir(USB_MEDIA_PATH):
        print "USB RaspMedia directory present"
        return True

def CopyMediaFiles():
    print "Copying files from USB to RaspMedia Player"
    clear = True
    # search for update indicator file
    for file in os.listdir(USB_MEDIA_PATH):
        if not file.endswith((SUPPORTED_IMAGE_EXTENSIONS)) and not file.endswith((SUPPORTED_VIDEO_EXTENSIONS)) and file.startswith('update'):
            clear = False
            config = configtool.readConfig()
            try:
                configDict = ast.literal_eval(config)
                config = configDict
            except:
                pass
            imgEnabled = config["image_enabled"]
            vidEnabled = config["video_enabled"]
    if clear:
        shutil.rmtree(MEDIA_PATH)
        if not os.path.isdir(MEDIA_PATH):
            os.mkdir(MEDIA_PATH)<commit_msg>Log info.<commit_after>#! /usr/bin/env python

import os, sys, subprocess, time, shutil, Image, threading, random
import urllib2
from constants import *
from packages.rmconfig import configtool

ROOT_PATH = "/home/pi/raspmedia/"
MEDIA_PATH = ROOT_PATH + "Raspberry/media"
USB_PATH = "/media/usb0/"
USB_MEDIA_PATH = USB_PATH + 'raspmedia'

def UsbDrivePresent():
    proc = subprocess.Popen(["ls /dev | grep 'sda'"], stdout=subprocess.PIPE, shell=True)
    (out, err) = proc.communicate()
    if 'sda' in out:
        return True
    else:
        return False

def RaspMediaFilesPresent():
    # check if usb contains kiosk directory
    if os.path.isdir(USB_MEDIA_PATH):
        print "USB RaspMedia directory present"
        return True

def CopyMediaFiles():
    print "Copying files from USB to RaspMedia Player"
    clear = True
    # search for update indicator file
    for file in os.listdir(USB_MEDIA_PATH):
        if not file.endswith((SUPPORTED_IMAGE_EXTENSIONS)) and not file.endswith((SUPPORTED_VIDEO_EXTENSIONS)) and file.startswith('update'):
            # file indicating a file update found, load config and set flag
            print "File to indicate a media file update found."
            print "Current files on the player will not be deleted."
            print "Existing files with the same name as a new media file will be overwritten."
            clear = False
            config = configtool.readConfig()
            try:
                configDict = ast.literal_eval(config)
                config = configDict
            except:
                pass
            imgEnabled = config["image_enabled"]
            vidEnabled = config["video_enabled"]
    if clear:
        # delete previous files from player
        shutil.rmtree(MEDIA_PATH)
        if not os.path.isdir(MEDIA_PATH):
            os.mkdir(MEDIA_PATH)
{'fraction_non_alphanumeric': 0.08865671641791045, 'fraction_numerical': 0.0011940298507462687, 'mean_word_length': 2.642391304347826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4101755', 'n_tokens_mistral': 1003, 'n_tokens_neox': 981, 'n_words': 290}