def __init__(self): global builder, window if api.call_api("execute.auth", [], db.getOne('token')) == True: self.token, self.user_id = db.getOne('token'), db.getOne('user_id') else: self.gui() self.token, self.user_id = db.getOne('token'), db.getOne('user_id') if api.call_api("execute.auth", [], self.token) != True: self.__init__()
def do_GET(self): # Look for main page if self.path == "/": self.path = "/index.html" if self.path == "/products": #send response code: self.send_response(200) #send headers: self.send_header("Content-type:", "application/json") # send a blank line to end headers: self.wfile.write("\n") #send response: json.dump(db.getAll(), self.wfile) if re.match(r'\/product\/\d+', self.path): # match "/product/{ID}" #send response code: self.send_response(200) #send headers: self.send_header("Content-type:", "application/json") # send a blank line to end headers: self.wfile.write("\n") #send response: json.dump( db.getOne(re.search(r'[^/]*$', self.path).group(0)), self.wfile) # regex to get everything after the last slash try: #Check the file extension required and #set the right mime type sendReply = False if self.path.endswith(".html"): mimetype = 'text/html' sendReply = True if self.path.endswith(".woff"): mimetype = 'font/opentype' sendReply = True if self.path.endswith(".ttf"): mimetype = 'font/opentype' sendReply = True if self.path.endswith(".js"): mimetype = 'application/javascript' sendReply = True if self.path.endswith(".css"): mimetype = 'text/css' sendReply = True if sendReply == True: #Open the static file requested and send it f = open(curdir + sep + self.path) self.send_response(200) self.send_header('Content-type', mimetype) self.end_headers() self.wfile.write(f.read()) f.close() return except IOError: self.send_error(404, 'File Not Found: %s' % self.path)
def do_GET(self) : # Look for main page if self.path=="/": self.path="/index.html" if self.path == "/products" : #send response code: self.send_response(200) #send headers: self.send_header("Content-type:", "application/json") # send a blank line to end headers: self.wfile.write("\n") #send response: json.dump(db.getAll(), self.wfile) if re.match(r'\/product\/\d+', self.path): # match "/product/{ID}" #send response code: self.send_response(200) #send headers: self.send_header("Content-type:", "application/json") # send a blank line to end headers: self.wfile.write("\n") #send response: json.dump(db.getOne(re.search(r'[^/]*$', self.path).group(0)), self.wfile) # regex to get everything after the last slash try: #Check the file extension required and #set the right mime type sendReply = False if self.path.endswith(".html"): mimetype='text/html' sendReply = True if self.path.endswith(".woff"): mimetype='font/opentype' sendReply = True if self.path.endswith(".ttf"): mimetype='font/opentype' sendReply = True if self.path.endswith(".js"): mimetype='application/javascript' sendReply = True if self.path.endswith(".css"): mimetype='text/css' sendReply = True if sendReply == True: #Open the static file requested and send it f = open(curdir + sep + self.path) self.send_response(200) self.send_header('Content-type',mimetype) self.end_headers() self.wfile.write(f.read()) f.close() return except IOError: self.send_error(404,'File Not Found: %s' % self.path)
def get_weibo_message(self): res = db.getOne() if res is None: print res logger.info('none crawler content') return None print res[0], res[1], res[2], res[3], res[4], res[5] self.md5 = res[4] content = res[1] #remove url content = remove_urls(content) print 'after remove url ', content images = [] if len(res[2]) > 0: images = res[2].split(' ') weibo = WeiboMessage(content, images) return weibo
def get(prop): sql = "select %s from Allowances where ID = %s" params = (prop, self.ID) return db.getOne(sql, params)
def getClientContactDetails(ClientID): sql = "select Suffix, FirstName, MiddleName, LastName, BirthDate, Landline, MobileNo from ClientContactPersons where ClientID = %s" return db.getOne(sql, ClientID)
def get(prop): sql = "select %s from UniformDeposits where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from Detachments where ClientID = %s" params = (prop, self.ID) return db.getOne(sql, params)
def getDescription(FEtype): sql = 'select Description from FieldEmployeeTypes where type = %s' return db.getOne(sql, FEtype)
def get(prop): sql = "select %s from IncentiveMOR where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from PersonalPayables where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from PayrollRecord where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from OfficeEmployeeTypes where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from HolidayMOR where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def getDescription(HolidayMorType): sql = "select Description from HolidayMOR where Type = %s" return db.getOne(sql, HolidayMorType)
def get(prop): sql = "select %s from PersonalPayables where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def getDescription(RateTypes): sql = "select Description from RateTypes where Type = %s" return db.getOne(sql, RateTypes)
def get(prop): sql = "select %s from PagibigSalaryLoans where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from DetachmentContactPersons where DetachID = %s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from SSSContributions where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from Receivables where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from ManHourLogs where ID = %s" params = (prop, self.ID) return db.getOne(sql, params)
def getFieldEmployee(ID): sql = "select Type, Username, Password, Suffix, LastName, FirstName, MiddleName, Landline, MobileNo, Address, BirthDate, Gender, CivilStatus, Dependents, Position, DateHired, DateResigned, EmpStatus from FieldEmployee where ID = %s" return db.getOne(sql, ID)
def getClient(Code): sql = "select Name, BillingAddress, Landline from Clients where Code = %s" return db.getOne(sql, Code)
def get(prop): sql = "select %s from FieldEmployees where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from UniformDeposits where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from HolidayMOR where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from AuthorizedManHours where ID = %s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from Rates where ID = %s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from OfficeEmployees where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from SSSContributions where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from PagibigSalaryLoans where ID=%s" params =(prop, self.ID) return db.getOne(sql, params)
def getDescription(IncentiveMorType): sql = "select Description from IncentiveMOR where Type = %s" return db.getOne(sql, IncentiveMorType)
def get(prop): sql = "select %s from IncentiveMOR where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)
def get(prop): sql = "select %s from PayrollRecord where ID=%s" params = (prop, self.ID) return db.getOne(sql, params)