<commit_before>#Importing Adafruit_CharLCD library and Configuring LCD
import Adafruit_CharLCD as LCD
lcd = LCD.Adafruit_CharLCD(27,22,25,24,23,18,16,2,4)

#Importing other things like FTP and datetime tags
from ftplib import FTP
from datetime import datetime
import sys, time, json, os, os.path

#Loading config.json file
if (os.path.isfile('config.json') == True):
    cfgfile = open('config.json','r')
    config = json.load(cfgfile)
    cfgfile.close()
else: #If there is no config, ask for info
    server = raw_input("Server ip: ")
    username = raw_input("Username: ")
    password = raw_input("Password: ")
    directory = raw_input("Directory: ")
    debug = raw_input("Debug Output(y/n)?:")
    config = {'server':server,
              'username':username,
              'password':password,
              'directory':directory,
              'debug':debug}
    cfgfile = open('config.json','w')
    json.dump(config,cfgfile)
    cfgfile.close()

#Functions:
def genFileCache():
    cache = list(listdir(config['directory']))
    return cache
def debug(text):
    if (config['debug'] == 'y'):
        print(text)

def disp(text, delay=None):
    lcd.clear()
    lcd.message(text)
    if (delay != None):
        time.sleep(delay)

def status(message):
    lcd.clear()
    lcd.message("  " + datetime.now().strftime('%b %d %H:%M') + "\n" + message)


#Declaring FTP
ftp = FTP(config['server'])

try:
    ftp.login(config['username'],config['password'])
    debug("Login Successful to " + config['server'],1)
    disp("Connected to:\n" + config['server'])
except ftplib.all_errors:
    debug("Cannot connect to " + config['server'])
    disp("Connection Error\n" + config['server'],1)
    status("Connection Error")
    sys.exit()

localfiles = list(genFileCache()) #Declares localfiles as filelist   
remotefiles = ftp.nlist() #Getting filelist from server  
#Checking what server has more than local, and queuing to download
downloadList = list(set(remotefiles) - set(localfiles))

if (len(downloadList) == 0):
    debug("All files up to date, exiting...")
    disp("All files are\nup to date!",2)
    status("   All Synced")
    sys.exit()

itemCount = len(downloadList) #Total number of items to be downloaded<commit_msg>minor fixes<commit_after>#Importing Adafruit_CharLCD library and Configuring LCD
import Adafruit_CharLCD as LCD
lcd = LCD.Adafruit_CharLCD(27,22,25,24,23,18,16,2,4)

#Importing other things like FTP and datetime tags
from ftplib import FTP
from datetime import datetime
import sys, time, json, os, os.path

#Loading config.json file
if (os.path.isfile('config.json') == True):
    cfgfile = open('config.json','r')
    config = json.load(cfgfile)
    cfgfile.close()
else: #If there is no config, ask for info
    server = raw_input("Server ip: ")
    username = raw_input("Username: ")
    password = raw_input("Password: ")
    directory = raw_input("Directory: ")
    debug = raw_input("Debug Output(y/n)?:")
    config = {'server':server,
              'username':username,
              'password':password,
              'directory':directory,
              'debug':debug}
    cfgfile = open('config.json','w')
    json.dump(config,cfgfile)
    cfgfile.close()

#Functions:
def genFileCache():
    cache = list(listdir(config['directory']))
    return cache
def debug(text):
    if (config['debug'] == 'y'):
        print(text)

def disp(text, delay=None):
    lcd.clear()
    lcd.message(text)
    if (delay != None):
        time.sleep(delay)

def status(message):
    lcd.clear()
    lcd.message("  " + datetime.now().strftime('%b %d %H:%M') + "\n" + message)


#Declaring FTP
ftp = FTP(config['server'])

try:
    ftp.login(config['username'],config['password'])
    debug("Login Successful to " + config['server'],1)
    disp("Connected to:\n" + config['server'])
except:
    debug("Cannot connect to " + config['server'])
    disp("Connection Error\n" + config['server'],1)
    status("Connection Error")
    sys.exit()

localfiles = list(genFileCache()) #Declares localfiles as filelist   
remotefiles = ftp.nlist() #Getting filelist from server  
#Checking what server has more than local, and queuing to download
downloadList = list(set(remotefiles) - set(localfiles))

if (len(downloadList) == 0):
    debug("All files up to date, exiting...")
    disp("All files are\nup to date!",2)
    status("   All Synced")
    sys.exit()

itemCount = len(downloadList) #Total number of items to be downloaded
{'fraction_non_alphanumeric': 0.14860611510791366, 'fraction_numerical': 0.008992805755395683, 'mean_word_length': 3.76338329764454, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7598359', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1416, 'n_words': 369}