<commit_before>#!/usr/bin/env python3
# Copyright 2014-2019 <NAME> <<EMAIL>>

from connect import connect
from datetime import datetime

commandFile = 'keithley.txt' # Name of file with commands

# Sends a command and prints the error status
def command(socket, line):
    line = line.strip()              # Remove extra whitespace
    if not line             : return # Empty line
    if line.startswith('%') : return # Comment
    socket.sendall((line + '\n').encode())
    print(line)
    socket.sendall('system:error?\n'.encode())
    print(socket.recv(4096).decode().strip())

s = connect()
command(s, 'system:clear') # Clear error queue

# Set date and time
now = datetime.now()
command(s, 'system:date {0}, {1}, {2}'.format(now.date().year, now.date().month, now.date().day))
command(s, 'system:time {0}, {1}, {2}'.format(now.time().hour, now.time().minute, now.time().second))

# Load commands from file and send to device
with open(commandFile, 'rt') as f :
    for line in f :
        command(s, line)
s.close()<commit_msg>suppress error message when there is no error<commit_after>#!/usr/bin/env python3
# Copyright 2014-2019 <NAME> <<EMAIL>>

from connect import connect
from datetime import datetime

commandFile = 'keithley.txt' # Name of file with commands

# Sends a command and prints the error status
def command(socket, line):
    line = line.strip()              # Remove extra whitespace
    if not line             : return # Empty line
    if line.startswith('%') : return # Comment
    socket.sendall((line + '\n').encode())
    print(line)
    socket.sendall('system:error?\n'.encode())
    response= socket.recv(4096).decode().strip()
    if not response.startswith('0,') :
        print('Error: ', response)

s = connect()
command(s, 'system:clear') # Clear error queue

# Set date and time
now = datetime.now()
command(s, 'system:date {0}, {1}, {2}'.format(now.date().year, now.date().month, now.date().day))
command(s, 'system:time {0}, {1}, {2}'.format(now.time().hour, now.time().minute, now.time().second))

# Load commands from file and send to device
with open(commandFile, 'rt') as f :
    for line in f :
        command(s, line)
s.close()
{'fraction_non_alphanumeric': 0.16, 'fraction_numerical': 0.01793103448275862, 'mean_word_length': 3.6595289079229123, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '441788', 'n_tokens_mistral': 706, 'n_tokens_neox': 683, 'n_words': 210}