Beispiel #1
0
    def _get_content(self):
        """read image content"""

        if os.path.getsize(self.path) > 2 * 1024 * 1024:
            Log.fatal('image file size too large')
        else:
            with open(self.path, 'rb') as f:
                self.content = f.read()
Beispiel #2
0
def callout_post(req):
    try:
        # post data to server
        resp = urllib2.urlopen(req, timeout=5)
        # get response
        qrcont = resp.read()
        return qrcont
    except urllib2.HTTPError as e:
        Log.fatal(e.read())
    return None
Beispiel #3
0
def _setup_apiobj(self, api, path):
    if self is not api:
        Log.debug('self is not api')
        self._api = api
        self._urlbase = api.server + '/'.join(path)

    lvl = len(path)
    done = set()
    for i in _APIS:
        if len(i) <= lvl:
            continue
        cur = i[lvl]
        if i[:lvl] == path and cur not in done:
            done.add(cur)
            setattr(self, cur, _APIProxy(api, i[:lvl + 1]))
Beispiel #4
0
def create_request(http_url, **payload):
    Log.info('url : ' + http_url)
    boundary = '----------%s' % hex(int(time.time() * 1000))
    data = []
    for (k, v) in payload.iteritems():
        Log.debug('key :' + k)
        Log.debug('value :' + v)
        data.append('--%s' % boundary)
        data.append('Content-Disposition: form-data; name="%s"\r\n' % k)
        data.append(v)
    data.append('--%s--\r\n' % boundary)
    http_body = '\r\n'.join(data)
    Log.info(http_body)
    # buld http request
    req = urllib2.Request(http_url)
    # header
    req.add_header('Content-Type',
                   'multipart/form-data; boundary=%s' % boundary)
    req.add_data(http_body)
    return req
Beispiel #5
0
 def __init__(self, api, path):
     Log.debug('_APIProxy called')
     _setup_apiobj(self, api, path)
Beispiel #6
0
 def __init__(self, key, secret, server):
     self.key = key
     self.secret = secret
     self.server = server
     Log.debug('API called')
     _setup_apiobj(self, self, [])
Beispiel #7
0
	def insert(generator, table_name, log_filename):
		gw2db = Gw2Database(autocommit = True)
		counter = 0 
		
		print('Inserting...')
		log = Log(log_filename, paths.logs)
		log.write(str(gw2db.get_columns(table_name)), end='\n\n')
		for row in generator:		
			print(row)
			try:
				gw2db.insert_to_table(table_name, *row) 
			except:
				counter += 1
				log.write(str(row))
				log.write(str(sys.exc_info()[1]), end = ' ')
				log.write('--------------------------')
		print('Done')
		
		log.write('{} rows were not inserted'.format(counter))
		log.write('Log created {}'.format(str(datetime.datetime.now())))
Beispiel #8
0
from utilities.log import Log
import logging
import numpy as np
from ate_settings import *
import re

DEBUG_MODE = False
# global logging variable
# instantiated once first time this module is loaded
# Five log levels - CRITICAL, ERROR, WARNING, INFO, and DEBUG
# For development, set to DEBUG.  For production, set to WARNING.
if DEBUG_MODE == True:
    log = Log(logging.DEBUG)
else:
    log = Log(logging.INFO)

DEVICE_TYPE = 'Diana'
MCU = 'Apollo2'
FONT_FILE_PATH = '/home/pi/misfit/ShineProduction/newATE/tests/diana_fonts_unhinted_cjk.fmp'
PROJECT_PATH = '/home/pi/misfit/ShineProduction/newATE/'
DESKTOP_PATH = "/home/pi/Desktop/"
# projects
projectList = ["Diana"]

#===============================================================================
# STATION SOFTWARE VERSION
#===============================================================================
#Version scheme is defined as
#<station_type>.<product>.<major>.<minor>.<internal_rev>.<prod | dev>

STATION = "ATE"  # Can be either ATE or RMA