<commit_before>#! /usr/bin/python
#
# sudo python display_metric.py domain_name.com metric_id
#
# Fetches decimal numbers from simple webs service and displays 
# them on 7 segment diaplsys. Uses 74HCT595 shift registers connected
# to 74LS274 BCD-to-7-Segment decoders.

import bcd

import json
import time
import os
import sys
import urllib2

def main():

  args=sys.argv
  if len(args) < 3:
    print "usage %s url metric_id" % args[0]
    sys.exit()
 
  url = "http://" + os.getenv("metricsinyourfaceurl", args[1]) + "/getvalue?id=" + args[2]
  bcd.setup()

  while (True):
    # getting the value from the cloud
    try: 
      response = urllib2.urlopen(url)
      data = json.loads(response.read().decode('utf-8'))
      # displaying the value
      if "value" in data:
        bcd.output(int(data["value"]))
    except(urllib2.URLError):
      print("could not reach server")
    except(ValueError):
      print("invalid value")

    time.sleep(2)

  # resetting GPIO messes up display
  bcd.cleanup()

main()
<commit_msg>Fixed typo in comment<commit_after>#! /usr/bin/python
#
# sudo python display_metric.py domain_name.com metric_id
#
# Fetches decimal numbers from simple webs service and displays 
# them on 7 segment displays. Uses 74HCT595 shift registers connected
# to 74LS274 BCD-to-7-Segment decoders.

import bcd

import json
import time
import os
import sys
import urllib2

def main():

  args=sys.argv
  if len(args) < 3:
    print "usage %s url metric_id" % args[0]
    sys.exit()
 
  url = "http://" + os.getenv("metricsinyourfaceurl", args[1]) + "/getvalue?id=" + args[2]
  bcd.setup()

  while (True):
    # getting the value from the cloud
    try: 
      response = urllib2.urlopen(url)
      data = json.loads(response.read().decode('utf-8'))
      # displaying the value
      if "value" in data:
        bcd.output(int(data["value"]))
    except(urllib2.URLError):
      print("could not reach server")
    except(ValueError):
      print("invalid value")

    time.sleep(2)

  # resetting GPIO messes up display
  bcd.cleanup()

main()

{'fraction_non_alphanumeric': 0.12088974854932302, 'fraction_numerical': 0.020309477756286266, 'mean_word_length': 3.274793388429752, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3793817', 'n_tokens_mistral': 736, 'n_tokens_neox': 696, 'n_words': 201}