def xmlrpc_existRollOver(self,queryParams): """ Purpose: - This is to check if given organisation has rollovered - if it return ``rollover_exit`` then it cannot rollover again - else it return ``rollover_notexist`` then it is capable to rollover to next financial year Input: - orgname,financilefrom,financialto Output: - if rolloverflag is ``1`` then ``rollover_exit`` - else rollover_notexist """ orglist = dbconnect.getOrgList() flaglist = [] for org in orglist: orgname = org.find("orgname") financialyear_from = org.find("financial_year_from")#DD-MM-YYYY financialyear_to = org.find("financial_year_to") if (orgname.text == queryParams[0] and financialyear_from.text == queryParams[1] and financialyear_to.text == queryParams[2]): rolloverflag = org.find("rolloverflag").text if rolloverflag == str(1): return True else: return False else: pass
def xmlrpc_getFinancialYear(self,arg_orgName): """ purpose: This function will return a list of financial years for the given organisation. Arguements, Input: [organisationname] Output: returns financialyear list for peritcular organisation in the format "dd-mm-yyyy" """ #get the list of organisations from the /opt/abt/abt.xml file. #we will call the getOrgList function to get the nodes. orgs = dbconnect.getOrgList() #Initialising an empty list to be filled with financial years financialyearlist = [] for org in orgs: orgname = org.find("orgname") if orgname.text == arg_orgName: financialyear_from = org.find("financial_year_from") financialyear_to = org.find("financial_year_to") from_and_to = [financialyear_from.text, financialyear_to.text] financialyearlist.append(from_and_to) print "financialyearlist" print financialyearlist return financialyearlist
def xmlrpc_getFinancialYear(self, arg_orgName): """ purpose: This function will return a list of financial years for the given organisation. Arguements, Input: [organisationname] Output: returns financialyear list for peritcular organisation in the format "dd-mm-yyyy" """ # get the list of organisations from the /opt/abt/abt.xml file. # we will call the getOrgList function to get the nodes. orgs = dbconnect.getOrgList() # Initialising an empty list to be filled with financial years financialyearlist = [] for org in orgs: orgname = org.find("orgname") if orgname.text == arg_orgName: financialyear_from = org.find("financial_year_from") financialyear_to = org.find("financial_year_to") from_and_to = [financialyear_from.text, financialyear_to.text] financialyearlist.append(from_and_to) print "financialyearlist" print financialyearlist return financialyearlist
def xmlrpc_getOrganisationNames(self): """ Purpose: This function is used to return the list of organsation names found in abt.xml located at /opt/abt/ Output: Returns a list of organisation names already present in the file """ # calling the function getOrgList for getting list of organisation nodes. orgs = dbconnect.getOrgList() # initialising an empty list for organisation names orgnames = [] for org in orgs: # find orgname tag in abt.xml file orgname=org.find("orgname") # append the distinct orgname if orgname.text not in orgnames: orgnames.append(orgname.text) return orgnames
def xmlrpc_getOrganisationNames(self): """ Purpose: This function is used to return the list of organsation names found in abt.xml located at /opt/abt/ Output: Returns a list of organisation names already present in the file """ # calling the function getOrgList for getting list of organisation nodes. orgs = dbconnect.getOrgList() # initialising an empty list for organisation names orgnames = [] for org in orgs: # find orgname tag in abt.xml file orgname = org.find("orgname") # append the distinct orgname if orgname.text not in orgnames: orgnames.append(orgname.text) return orgnames
def getListOfFinancialYear(self,arg_orgName): ''' * Purpose: - get the list of organisations from the /opt/abt/abt.xml file. - call the getOrgList function to get the nodes. * Input: - [organisation name] ''' orgs = dbconnect.getOrgList() #Initialising an empty list to be filled with financial years financialyearlist = [] for org in orgs: orgname = org.find("orgname") if orgname.text == arg_orgName: financialyear_from = org.find("financial_year_from") financialyear_to = org.find("financial_year_to") from_and_to = [financialyear_from.text, financialyear_to.text] financialyearlist.append(from_and_to) financialyearlist.sort(reverse=True) return financialyearlist
def xmlrpc_getOrganisationNames(self): ''' * Purpose: - function is used to return the list of organsation names found in abt.xml located at /opt/abt/ - we have imported ``ElementTree`` for parsing xml file. * Output: - returns a list of organisation names already present in the file ''' # calling the function getOrgList for getting list of organisation nodes. print "org name" orgs = dbconnect.getOrgList() # initialising an empty list for organisation names orgnames = [] for org in orgs: # find orgname tag in abt.xml file orgname=org.find("orgname") # append the distinct orgname if orgname.text not in orgnames: orgnames.append(orgname.text) orgnames.sort() print "list" return orgnames
def xmlrpc_exportOrganisation(self,queryParams,client_id): """ * Purpose: - backup all the tables and values of oraganisation database in /opt/abt/export/*dbname and add organisation tags in /opt/abt/export/bckp.xml file * Input: - [organisationName,financialFrom,financialTo],client_id * Output: - export database and add tag in bckp.xml - return encrypted dbname """ print "queyParams" print queryParams #find the database name for selected organisation financialFrom = queryParams[1] financialTo = queryParams[2] orgs = dbconnect.getOrgList() for org in orgs: orgname = org.find("orgname") financialyear_from = org.find("financial_year_from")#DD-MM-YYYY financialyear_to = org.find("financial_year_to") if (orgname.text == queryParams[0] and financialyear_from.text == financialFrom and financialyear_to.text == financialTo): dbname = org.find("dbname") rollover_flag = org.find("rolloverflag") database = dbname.text print rollover_flag.text queryParams.append(database) queryParams.append(rollover_flag.text) print "the current database name is " + database try: #encrypt the database name encrypted_db = blankspace.remove_whitespaces([database.rstrip()]) #dump the create and insert queries of sqlite database os.system("sqlite3 /opt/abt/db/"+database+" .dump > /opt/abt/export/"+encrypted_db[0]) os.system("chmod 722 /opt/abt/export/"+encrypted_db[0]) #create bckp.xml file if not exist and add the organisation related tags if os.path.exists("/opt/abt/export/bckp.xml") == False: print "file not found trying to create one." try: os.system("touch /opt/abt/export/bckp.xml") print "file created " os.system("chmod 722 /opt/abt/export/bckp.xml") print "permissions granted " abtconf = open("/opt/abt/export/bckp.xml", "a") abtconf.write("<abt>\n") abtconf.write("</abt>") abtconf.close() self.xmlrpc_writeToXmlFile(queryParams,"/opt/abt/export/bckp.xml"); except: print "the software is finding trouble in creating file." return False else: self.xmlrpc_writeToXmlFile(queryParams,"/opt/abt/export/bckp.xml"); except: print "problem in backup database" return encrypted_db[0]