Beispiel #1
0
    def restore_database(target, source, user, password):
        from frappe.utils import make_esc
        esc = make_esc('$ ')

        from distutils.spawn import find_executable
        pv = find_executable('pv')
        if pv:
            pipe = '{pv} {source} |'.format(pv=pv, source=source)
            source = ''
        else:
            pipe = ''
            source = '< {source}'.format(source=source)

        if pipe:
            print('Restoring Database file...')

        command = '{pipe} mysql -u {user} -p{password} -h{host} ' + (
            '-P{port}' if frappe.db.port else '') + ' {target} {source}'
        command = command.format(pipe=pipe,
                                 user=esc(user),
                                 password=esc(password),
                                 host=esc(frappe.db.host),
                                 target=esc(target),
                                 source=source,
                                 port=frappe.db.port)
        os.system(command)
Beispiel #2
0
	def restore_database(self,target,source,user,password):
		from frappe.utils import make_esc
		esc = make_esc('$ ')

		from distutils.spawn import find_executable
		pipe = find_executable('pv')
		if pipe:
			pipe   = '{pipe} {source} |'.format(
				pipe   = pipe,
				source = source
			)
			source = ''
		else:
			pipe   = ''
			source = '< {source}'.format(source = source)

		if pipe:
			print('Creating Database...')

		command = '{pipe} mysql -u {user} -p{password} -h{host} {target} {source}'.format(
			pipe = pipe,
			user = esc(user),
			password = esc(password),
			host     = esc(frappe.db.host),
			target   = esc(target),
			source   = source
		)
		os.system(command)
 def bifurcate_based_on_type(self, doctype_name, total, av_dis, based_on,
                             doc_obj, val, company):
     add_cond = ''
     auth_value = av_dis
     if val == 1: add_cond += " and system_user = '******'user'] + "'"
     elif val == 2:
         add_cond += " and system_role IN %s" % (
             "('" + "','".join(frappe.user.get_roles()) + "')")
     else:
         add_cond += " and ifnull(system_user,'') = '' and ifnull(system_role,'') = ''"
     if based_on == 'Grand Total': auth_value = total
     elif based_on == 'Customerwise Discount':
         if doc_obj:
             if doc_obj.doc.doctype == 'Sales Invoice':
                 customer = doc_obj.doc.customer
             else:
                 customer = doc_obj.doc.customer_name
             add_cond = " and master_name = '" + make_esc("'")(
                 cstr(customer)) + "'"
     if based_on == 'Itemwise Discount':
         if doc_obj:
             for t in getlist(doc_obj.doclist, doc_obj.fname):
                 self.validate_auth_rule(doctype_name,
                                         t.discount_percentage, based_on,
                                         add_cond, company, t.item_code)
     else:
         self.validate_auth_rule(doctype_name, auth_value, based_on,
                                 add_cond, company)
Beispiel #4
0
    def restore_database(self, target, source, user, password):
        from frappe.utils import make_esc

        esc = make_esc("$ ")
        os.system(
            "mysql -u %s -p%s -h%s %s < %s" % (esc(user), esc(password), esc(frappe.db.host), esc(target), source)
        )
Beispiel #5
0
    def restore_database(target, source, user, password):
        from frappe.utils import make_esc

        esc = make_esc("$ ")

        from distutils.spawn import find_executable

        pv = find_executable("pv")
        if pv:
            pipe = "{pv} {source} |".format(pv=pv, source=source)
            source = ""
        else:
            pipe = ""
            source = "< {source}".format(source=source)

        if pipe:
            print("Restoring Database file...")

        command = ("{pipe} mysql -u {user} -p{password} -h{host} " +
                   ("-P{port}" if frappe.db.port else "") +
                   " {target} {source}")
        command = command.format(
            pipe=pipe,
            user=esc(user),
            password=esc(password),
            host=esc(frappe.db.host),
            target=esc(target),
            source=source,
            port=frappe.db.port,
        )
        os.system(command)
Beispiel #6
0
	def restore_database(self,target,source,user,password):
		from frappe.utils import make_esc
		esc = make_esc('$ ')
		
		try:
			ret = os.system("mysql -u %s -p%s %s < %s" % \
				(esc(user), esc(password), esc(target), source))
		except Exception,e:
			raise
	def bifurcate_based_on_type(self, doctype_name, total, av_dis, based_on, doc_obj, val, company):
		add_cond = ''
		auth_value = av_dis
		if val == 1: add_cond += " and system_user = '******'user']+"'"
		elif val == 2: add_cond += " and system_role IN %s" % ("('"+"','".join(frappe.user.get_roles())+"')")
		else: add_cond += " and ifnull(system_user,'') = '' and ifnull(system_role,'') = ''"
		if based_on == 'Grand Total': auth_value = total
		elif based_on == 'Customerwise Discount':
			if doc_obj:
				if doc_obj.doctype == 'Sales Invoice': customer = doc_obj.customer
				else: customer = doc_obj.customer_name
				add_cond = " and master_name = '"+make_esc("'")(cstr(customer))+"'"
		if based_on == 'Itemwise Discount':
			if doc_obj:
				for t in doc_obj.get(doc_obj.fname):
					self.validate_auth_rule(doctype_name, t.discount_percentage, based_on, add_cond, company,t.item_code )
		else:
			self.validate_auth_rule(doctype_name, auth_value, based_on, add_cond, company)
Beispiel #8
0
 def restore_database(self, target, source, user, password):
     from frappe.utils import make_esc
     esc = make_esc('$ ')
     os.system("mysql -u %s -p%s -h%s %s < %s" % \
      (esc(user), esc(password), esc(frappe.db.host), esc(target), source))