<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, getopt, httplib, urllib, json, os
import oauth.oauth as oauth
from configobj import ConfigObj
from datetime import datetime
from tabulate import tabulate

PUBLIC_KEY = ''
PRIVATE_KEY = ''

TELLSTICK_TURNON = 1
TELLSTICK_TURNOFF = 2
TELLSTICK_BELL = 4
TELLSTICK_DIM = 16
TELLSTICK_UP = 128
TELLSTICK_DOWN = 256

SUPPORTED_METHODS = TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_BELL | TELLSTICK_DIM | TELLSTICK_UP | TELLSTICK_DOWN;

def printUsage():
	print("Usage: %s [ options ]" % sys.argv[0])
	print("")
	print("Options:")
	print("         -[lnfdbvh] [ --list ] [ --help ]")
	print("                      [ --on device ] [ --off device ] [ --bell device ]")
	print("                      [ --dimlevel level --dim device ]")
	print("                      [ --up device --down device ]")
	print("")
	print("       --list type (-l short option)")
	print("             List currently configured components of a defined type.")
	print("             Valid types are {devices, sensors}")
	print("")
	print("       --help (-h short option)")
	print("             Shows this screen.")
	print("")
	print("       --on device (-n short option)")
	print("             Turns on device. 'device' must be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --off device (-f short option)")
	print("             Turns off device. 'device' must be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --dim device (-d short option)")
	print("             Dims device. 'device' must be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("             Note: The dimlevel parameter must be set before using this option.")
	print("")
	print("       --dimlevel level (-v short option)")
	print("             Set dim level. 'level' should an integer, 0-255.")
	print("             Note: This parameter must be set before using dim.")
	print("")
	print("       --bell device (-b short option)")
	print("             Sends bell command to devices supporting this. 'device' must")
	print("             be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --up device")
	print("             Sends up command to devices supporting this. 'device' must")
	print("             be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --down device")
	print("             Sends down command to devices supporting this. 'device' must")
	print("             be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("Report bugs to <<EMAIL>>")

def listSensors():
	response = doRequest('sensors/list', {'includeValues': 1, 'includeIgnored': 1})
	print("Number of sensors: %i" % len(response['sensor']));
	table=[]
	headers=["ID", "Name", "Time", "Temp", "Humidity"]
	for sensor in response['sensor']:
		try:
			table.append((sensor['id'],
				sensor['name'],
				datetime.fromtimestamp(sensor['lastUpdated']),
				sensor['temp'],
				sensor['humidity']))
		except KeyError as ke:
			print("Missing key: %s for sensor name: %s" % (ke, sensor['name']))
	print tabulate(table, headers, tablefmt="simple")


def listDevices():
	response = doRequest('devices/list', {'supportedMethods': SUPPORTED_METHODS})
	print("Number of devices: %i" % len(response['device']));
	table=[]
	headers=["ID", "Name", "State"]
	for device in response['device']:
		if (device['state'] == TELLSTICK_TURNON):
			state = 'ON'
		elif (device['state'] == TELLSTICK_TURNOFF):
			state = 'OFF'
		elif (device['state'] == TELLSTICK_DIM):
			state = "DIMMED"
		elif (device['state'] == TELLSTICK_UP):
			state = "UP"
		elif (device['state'] == TELLSTICK_DOWN):
			state = "DOWN"<commit_msg>Silently discard entry rather than printing error text into data stream...<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, getopt, httplib, urllib, json, os
import oauth.oauth as oauth
from configobj import ConfigObj
from datetime import datetime
from tabulate import tabulate

PUBLIC_KEY = ''
PRIVATE_KEY = ''

TELLSTICK_TURNON = 1
TELLSTICK_TURNOFF = 2
TELLSTICK_BELL = 4
TELLSTICK_DIM = 16
TELLSTICK_UP = 128
TELLSTICK_DOWN = 256

SUPPORTED_METHODS = TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_BELL | TELLSTICK_DIM | TELLSTICK_UP | TELLSTICK_DOWN;

def printUsage():
	print("Usage: %s [ options ]" % sys.argv[0])
	print("")
	print("Options:")
	print("         -[lnfdbvh] [ --list ] [ --help ]")
	print("                      [ --on device ] [ --off device ] [ --bell device ]")
	print("                      [ --dimlevel level --dim device ]")
	print("                      [ --up device --down device ]")
	print("")
	print("       --list type (-l short option)")
	print("             List currently configured components of a defined type.")
	print("             Valid types are {devices, sensors}")
	print("")
	print("       --help (-h short option)")
	print("             Shows this screen.")
	print("")
	print("       --on device (-n short option)")
	print("             Turns on device. 'device' must be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --off device (-f short option)")
	print("             Turns off device. 'device' must be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --dim device (-d short option)")
	print("             Dims device. 'device' must be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("             Note: The dimlevel parameter must be set before using this option.")
	print("")
	print("       --dimlevel level (-v short option)")
	print("             Set dim level. 'level' should an integer, 0-255.")
	print("             Note: This parameter must be set before using dim.")
	print("")
	print("       --bell device (-b short option)")
	print("             Sends bell command to devices supporting this. 'device' must")
	print("             be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --up device")
	print("             Sends up command to devices supporting this. 'device' must")
	print("             be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("       --down device")
	print("             Sends down command to devices supporting this. 'device' must")
	print("             be an integer of the device-id")
	print("             Device-id and name is outputed with the --list option")
	print("")
	print("Report bugs to <<EMAIL>>")

def listSensors():
	response = doRequest('sensors/list', {'includeValues': 1, 'includeIgnored': 1})
	print("Number of sensors: %i" % len(response['sensor']));
	table=[]
	headers=["ID", "Name", "Time", "Temp", "Humidity"]
	for sensor in response['sensor']:
		try:
			table.append((sensor['id'],
				sensor['name'],
				datetime.fromtimestamp(sensor['lastUpdated']),
				sensor['temp'],
				sensor['humidity']))
		except KeyError as ke:
			#print("Missing key: %s for sensor name: %s" % (ke, sensor['name']))
                        :
	print tabulate(table, headers, tablefmt="simple")


def listDevices():
	response = doRequest('devices/list', {'supportedMethods': SUPPORTED_METHODS})
	print("Number of devices: %i" % len(response['device']));
	table=[]
	headers=["ID", "Name", "State"]
	for device in response['device']:
		if (device['state'] == TELLSTICK_TURNON):
			state = 'ON'
		elif (device['state'] == TELLSTICK_TURNOFF):
			state = 'OFF'
		elif (device['state'] == TELLSTICK_DIM):
			state = "DIMMED"
		elif (device['state'] == TELLSTICK_UP):
			state = "UP"
		elif (device['state'] == TELLSTICK_DOWN):
			state = "DOWN"
{'fraction_non_alphanumeric': 0.1478547050219405, 'fraction_numerical': 0.004631886884446611, 'mean_word_length': 2.786340562990309, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '279941', 'n_tokens_mistral': 2623, 'n_tokens_neox': 2498, 'n_words': 857}