def open(self): locator = dir_locator() self.path_dir = locator.module_path() self.path_dir += "\\debug" if not os.path.exists(self.path_dir): os.makedirs(self.path_dir) #open file for writing on it self.file = open(self.path_dir + "\\" + self.short_filename, "w") #start html document self.file.write("<html>\n") self.file.write("<body>\n") #write coordinates' table self.file.write("<table border=\"1\">\n") #write headers self.file.write("\t<tr>\n") self.file.write("\t<th width=\"80\">#</th>\n") self.file.write("\t<th width=\"100\">Type</th>\n") self.file.write("\t<th width=\"100\">Metadata</th>\n") self.file.write("\t<th width=\"140\">coord_X (twips)</th>\n") self.file.write("\t<th width=\"140\">coord_Y (twips)</th>\n") self.file.write("\t<th width=\"200\">Data</th>\n") self.file.write("</tr>\n")
def main(): locator = dir_locator() path_dir = locator.module_path() print "Executing json.php\n" subprocess.call("php \"" + path_dir + "\\json.php\"") print "\n" print "Executing printing...\n" full_filename = path_dir + '\\data.json.txt' filename = full_filename[full_filename.rindex('\\') + 1:] with open(full_filename, 'r') as content_file: content = content_file.read() d = DC_documentPrinter("Checks from account 0071", json.loads(content), "Check", "HP Deskjet 3510 series (Red)", True) d.printIt()