# Path: jasper_erpnext_report/utils/file.py
# def get_jasper_path(for_all_sites = False):
# 	if not for_all_sites:
# 		return 	get_site_path("jasper")
# 
# 	module_path = os.path.normpath(os.path.join(os.path.dirname(jasper_erpnext_report.__file__), "jasper"))
# 	return module_path
# 
# def get_file(path, modes="r", raise_not_found=False):
# 	if modes != "r":
# 		content = read_file(path, modes=modes, raise_not_found=raise_not_found)
# 	else:
# 		content = frappe.read_file(path, raise_not_found=raise_not_found)
# 
# 	return content
# 
# Path: jasper_erpnext_report/utils/jasper_file_jrxml.py
# def get_compiled_path(dir_path, dn):
# 	jrxml_path = get_jrxml_path(dir_path, dn)
# 	compiled_path = frappe.utils.get_path("compiled", base=jrxml_path)
# 	frappe.create_folder(compiled_path)
# 	return compiled_path


from frappe import _
from frappe.utils import cint
from jasper_erpnext_report.utils.file import get_jasper_path, get_file
from jasper_erpnext_report.utils.jasper_file_jrxml import get_compiled_path
		from jasper_erpnext_report.core.FrappeTask import FrappeTask
				from jasper_erpnext_report.utils.utils import get_hook_module
			from jasper_erpnext_report.jasper_reports.FrappeDataSource import _JasperCustomDataSource
			from jasper_erpnext_report.jasper_reports.ScriptletDefault import _JasperCustomScriptlet
			from jasper_erpnext_report.utils.utils import get_hook_module
				from jasper_erpnext_report.jasper_reports.ScriptletDefault import _JasperCustomScriptlet
import frappe
import jasper_erpnext_report.utils.utils as utils
import jasper_erpnext_report.jasper_reports as jr
import JasperBase as Jb
import os
				if isinstance(value, basestring) and value == 'None':
					value = ''
				row.append(value)
			tables.append(row)

		for k in columnNames:
			cols.append(k.get("name"))

		return tables, cols

	def polling(self, reqId):
		data = self.get_jasper_reqid_data(reqId)
		if not data['data']:
			frappe.throw(_("No report for this requestid %s." % reqId[13:]))

		output_path = data['data']['result'].get("uri")
		# check if file already exists but also check if is size is > 0 because java take some time to write to file after
		# create the file in disc
		if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
			res = self.prepareResponse({"reportURI": output_path, "status":"ready", "exports":[{"status":"ready", "id":reqId, "outputResource":{"fileName": data['data']['result'].get("fileName")}}]}, reqId)
			res["status"] = "ready"
		else:
			res = self.prepareResponse({}, reqId)
		return res

	def getLocalReport(self, reqId):
		data = self.get_jasper_reqid_data(reqId)
		if not data['data']:
			frappe.throw(_("No report for this requestid %s." % reqId))
		output_path = data['data']['result'].get("uri")

# Path: jasper_erpnext_report/utils/file.py
# def get_jasper_path(for_all_sites = False):
# 	if not for_all_sites:
# 		return 	get_site_path("jasper")
# 
# 	module_path = os.path.normpath(os.path.join(os.path.dirname(jasper_erpnext_report.__file__), "jasper"))
# 	return module_path
# 
# def get_file(path, modes="r", raise_not_found=False):
# 	if modes != "r":
# 		content = read_file(path, modes=modes, raise_not_found=raise_not_found)
# 	else:
# 		content = frappe.read_file(path, raise_not_found=raise_not_found)
# 
# 	return content
# 
# Path: jasper_erpnext_report/utils/jasper_file_jrxml.py
# def get_compiled_path(dir_path, dn):
# 	jrxml_path = get_jrxml_path(dir_path, dn)
# 	compiled_path = frappe.utils.get_path("compiled", base=jrxml_path)
# 	frappe.create_folder(compiled_path)
# 	return compiled_path


# Path: jasper_erpnext_report/core/JasperLocal.py
from frappe import _
from frappe.utils import cint
from jasper_erpnext_report.utils.file import get_jasper_path, get_file
from jasper_erpnext_report.utils.jasper_file_jrxml import get_compiled_path
		from jasper_erpnext_report.core.FrappeTask import FrappeTask
				from jasper_erpnext_report.utils.utils import get_hook_module
			from jasper_erpnext_report.jasper_reports.FrappeDataSource import _JasperCustomDataSource
			from jasper_erpnext_report.jasper_reports.ScriptletDefault import _JasperCustomScriptlet
			from jasper_erpnext_report.utils.utils import get_hook_module
				from jasper_erpnext_report.jasper_reports.ScriptletDefault import _JasperCustomScriptlet
import frappe
import jasper_erpnext_report.utils.utils as utils
import jasper_erpnext_report.jasper_reports as jr
import JasperBase as Jb
import os

				if isinstance(value, basestring) and value == 'None':
					value = ''
				row.append(value)
			tables.append(row)

		for k in columnNames:
			cols.append(k.get("name"))

		return tables, cols

	def polling(self, reqId):
		data = self.get_jasper_reqid_data(reqId)
		if not data['data']:
			frappe.throw(_("No report for this requestid %s." % reqId[13:]))

		output_path = data['data']['result'].get("uri")
		# check if file already exists but also check if is size is > 0 because java take some time to write to file after
		# create the file in disc
		if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
			res = self.prepareResponse({"reportURI": output_path, "status":"ready", "exports":[{"status":"ready", "id":reqId, "outputResource":{"fileName": data['data']['result'].get("fileName")}}]}, reqId)
			res["status"] = "ready"
		else:
			res = self.prepareResponse({}, reqId)
		return res

	def getLocalReport(self, reqId):
		data = self.get_jasper_reqid_data(reqId)
		if not data['data']:
			frappe.throw(_("No report for this requestid %s." % reqId))
		output_path = data['data']['result'].get("uri")

		content = get_file(output_path, "rb")