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

import urllib
#import urllib2
import getpass
import sys
import os
from optparse import OptionParser

DEBUG = False
NO_SSL = False # This should really only be set to True for testing.

LABTRACKER_URL = "labtracker.eplt.washington.edu"
if DEBUG:
    LABTRACKER_URL = "walnut.eplt.washington.edu:8000"
    import httplib
    httplib.HTTPConnection.debuglevel = 1
ACTIONS = ('login','logout','ping')

# functions at the module level must be defined
# before being called ;) 
def get_actions_list():
    global ACTIONS
    return ', '.join(ACTIONS)

parser = OptionParser()
parser.add_option("-a", "--action", dest="action", 
                help="Action of script: %s" % get_actions_list()) 

(options, args) = parser.parse_args()

def get_mac():
    # windows 
    if sys.platform == 'win32':
        for line in os.popen("ipconfig /all"):
            if line.lstrip().startswith('Physical Address'):
                possible_mac = line.split(':')[1].strip().replace('-',':')
            # On machines with multiple active interfaces, we want to send the MAC associated with the IPv4 Address
            elif line.lstrip().startswith('IPv4 Address'):
                mac = possible_mac
        return mac
    # os x 
    elif sys.platform == 'darwin':
        for line in os.popen("/sbin/ifconfig"):
            if line.lower().find('ether') > -1:
                mac = line.split()[1]
            	break
        return mac
    elif sys.platform == 'linux2':
        for line in os.popen("/sbin/ifconfig"):
            if line.lower().find('hwaddr') > -1:
                mac = line.split()[-1]
                break
        return mac

def get_data(status): 
    # get user info from machine
    user = getpass.getuser()
    data = urllib.urlencode({'user': user, 'status': status})
    return data

def _track(url, action, mac, data=None):
    """Lower level track function, useful for testing"""
    try:
    	import urllib2
        secure = ''
        if not NO_SSL:
            secure = 's'
        req = urllib2.Request(url="http%s://%s/tracker/%s/%s/" % (secure, url, action, mac),<commit_msg>changed tracker so that it sends multiple mac addresses<commit_after>#!/usr/bin/env python

import urllib
#import urllib2
import getpass
import sys
import os
from optparse import OptionParser

DEBUG = True 
NO_SSL = True# This should really only be set to True for testing.

LABTRACKER_URL = "labtracker.eplt.washington.edu"
if DEBUG:
    LABTRACKER_URL = "web2.eplt.washington.edu:8000"
    import httplib
    httplib.HTTPConnection.debuglevel = 1
ACTIONS = ('login','logout','ping')

# functions at the module level must be defined
# before being called ;) 
def get_actions_list():
    global ACTIONS
    return ', '.join(ACTIONS)

parser = OptionParser()
parser.add_option("-a", "--action", dest="action", 
                help="Action of script: %s" % get_actions_list()) 

(options, args) = parser.parse_args()

def get_mac():
    # windows 
    mac_addresses = ''
    if sys.platform == 'win32':
        for line in os.popen("ipconfig /all"):
            if line.lstrip().startswith('Physical Address'):
                mac = line.split(':')[1].strip().replace('-',':')
            if mac_addresses=='':
                mac_addresses=mac
            else:
                mac_addresses=mac_addresses+','+mac
        return mac_addresses
    # os x 
    elif sys.platform == 'darwin':
        for line in os.popen("/sbin/ifconfig"):
            if line.lower().find('ether') > -1:
                mac = line.split()[1]
                if mac_addresses=='':
                    mac_addresses=mac
                else:
                    mac_addresses=mac_addresses+','+mac
        return mac_addresses
    elif sys.platform == 'linux2':
        for line in os.popen("/sbin/ifconfig"):
            if line.lower().find('hwaddr') > -1:
                mac = line.split()[-1]
                if mac_addresses=='':
                    mac_addresses=mac
                else:
                    mac_addresses=mac_addresses+','+mac
        return mac_addresses

def get_data(status): 
    # get user info from machine
    user = getpass.getuser()
    data = urllib.urlencode({'user': user, 'status': status})
    return data

def _track(url, action, mac, data=None):
    """Lower level track function, useful for testing"""
    try:
    	import urllib2
        secure = ''
        if not NO_SSL:
            secure = 's'
        req = urllib2.Request(url="http%s://%s/tracker/%s/%s/" % (secure, url, action, mac),
{'fraction_non_alphanumeric': 0.1292591778412838, 'fraction_numerical': 0.007693998681028797, 'mean_word_length': 2.350515463917526, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1971300', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1377, 'n_words': 373}