コード例 #1
0
    def new_file(self, called_from_tutorial=False):

        self.BZMAN_settings = read_file(self.ctx.get_settings_file)

        if self.BZMAN_settings["path"] == "":

            inform_user(
                self, "Welcom to BZMAN! \n\n" +
                "Please select a folder to save your company database.")

            self.folder_path = QFileDialog.getExistingDirectory(
                self, 'Select a folder to save your database')

            if self.folder_path:

                self.BZMAN_settings["path"] = self.folder_path
                self._new_file_logic()

            else:
                inform_user(self, "No folder location selected.")

        else:
            ans = ask_user(
                self, "Company database already exists.\n\n" +
                "Do you still want to create a new database?\n\n")

            if ans == QMessageBox.Ok:
                self.BZMAN_settings["path"] = ""
                write_file(self.BZMAN_settings, self.ctx.get_settings_file)

                inform_user(
                    self,
                    "Your old database will now need to be manually opened using 'Open'\n\n"
                    + "You may now create a new database")
                self.new_file()
コード例 #2
0
    def set_new_file_location(self):
        ans = ask_user(
            self,
            "This will let 'B Z M A N' set a new path to your exisiting company database. "
            +
            "This means you will be able to open files that you have moved to a new location after saving them.\n\n"
            +
            "If you want to continue, click 'Ok'. If you want to exit, click 'Cancel'."
        )

        if ans == QMessageBox.Ok:
            filename = QFileDialog.getOpenFileName(
                self,
                "Open",
                self.BZMAN_settings['path'],
                filter="Database Files (*.json)")[0]
            if filename:
                new_path, new_filename = os.path.split(filename)
                new_company_name = ",".join(
                    os.path.split(
                        os.path.splitext(filename)[0])[1].split('_')[:-2])
                self.BZMAN_settings['path'] = new_path
                self.BZMAN_settings['database_name'] = new_filename
                self.BZMAN_settings['company'] = new_company_name
                write_file(self.BZMAN_settings, self.ctx.get_settings_file)
                inform_user(
                    self,
                    "New path to the company database has been set. You can now open the database using 'Open'"
                )

            else:
                inform_user(self, "Select a valid database file")
コード例 #3
0
    def _new_file_logic(self):
        dlg = QInputDialog(self)
        dlg.setInputMode(QInputDialog.TextInput)
        dlg.setWindowTitle('New Database : Enter Your Company Name')
        dlg.setLabelText('Company Name')
        dlg.resize(self.ctx.available_geo().width() / 3.42,
                   self.ctx.available_geo().height() / 17.44)
        ok = dlg.exec_()
        filename = dlg.textValue()

        if ok and filename:

            self.BZMAN_settings['company'] = filename
            self.BZMAN_settings[
                'database_name'] = filename + "_BZMAN_DATABASE.json"

            filename = os.path.join(self.folder_path + "/" + filename)
            self.database_filename = filename + "_BZMAN_DATABASE.json"

            new_database = list()
            write_file(new_database, self.database_filename)
            write_file(self.BZMAN_settings, self.ctx.get_settings_file)

            ans = inform_user(
                self, "Great! Company database created!\n\n" +
                "Click 'Ok' to open it.")

            if ans == QMessageBox.Ok:

                self.load_file()
                ans = ask_user(
                    self,
                    "There are no entries in your company database.\n\n" +
                    "You can now add a new customer by clicking on 'Create New Customer' option in the top left or by clicking 'Ok'.\n"
                )

                if ans == QMessageBox.Ok:
                    self.entry_panel = EntryPanel(self.database_filename,
                                                  self.ctx)
                    self.entry_panel.show()  #move this after opening file

        elif ok and not filename:
            inform_user(self,
                        "Company name was left blank. \nEnter a valid name.")
            self._new_file_logic()

        else:
            self.BZMAN_settings["path"] = ""
            write_file(self.BZMAN_settings, self.ctx.get_settings_file)
コード例 #4
0
ファイル: panels.py プロジェクト: SarthakJariwala/bzman
    def update_database(self):  #TODO: Catch user entering empty strings
        data_pkl = self._collect_widget_data()
        if data_pkl is not None:
            write_file(data_pkl, self.database_filename)
            answer = ask_user(
                self,
                "You can now add invoices for this company.\n\n" +
                "Do you want to start the account for this company by adding an invoice?\n\n",
            )

            if answer == QMessageBox.Ok:
                self.open_invoice_dialog()
            self.statusBar.showMessage("Entry Added!", 2000)
            for i in range(len(self.panel_entry)):
                try:
                    try:
                        self.panel_entry[i].ledit.setText("")
                    except:
                        self.panel_entry[i].tedit.setText("")
                except:
                    self.panel_entry[i].spin_box.setValue(0.00)
コード例 #5
0
ファイル: satsolver.py プロジェクト: ipfire/pakfire
	def DEADCODE(self):
		# If the solver succeeded, we return the transaction and return.
		if res:
			# Return a resulting Transaction.
			t = Transaction(solver)

			return transaction.Transaction.from_solver(self.pakfire, self, t)

		# Do the problem handling...
		problems = solver.get_problems(request)

		logger.info("")
		logger.info(_("The solver returned one problem:", "The solver returned %(num)s problems:",
			len(problems)) % { "num" : len(problems) })

		i = 0
		for problem in problems:
			i += 1

			# Print information about the problem to the user.
			logger.info("  #%d: %s" % (i, problem))

		logger.info("")

		if not interactive:
			return False

		# Ask the user if he or she want to modify the request. If not, just exit.
		if not util.ask_user(_("Do you want to manually alter the request?")):
			return False

		print _("You can now try to satisfy the solver by modifying your request.")

		altered = False
		while True:
			if len(problems) > 1:
				print _("Which problem to you want to resolve?")
				if altered:
					print _("Press enter to try to re-solve the request.")
				print "[1-%s]:" % len(problems),

				answer = raw_input()

				# If the user did not enter anything, we abort immediately.
				if not answer:
					break

				# If the user did type anything else than an integer, we ask
				# again.
				try:
					answer = int(answer)
				except ValueError:
					continue

				# If the user entered an integer outside of range, we ask
				# again.
				try:
					problem = problems[answer - 1]
				except KeyError:
					continue

			else:
				problem = problem[0]

			# Get all solutions.
			solutions = problem.get_solutions()

			if len(solutions) == 1:
				solution = solutions[0]
				print _("    Solution: %s") % solution
				print

				if util.ask_user("Do you accept the solution above?"):
					altered = True
					print "XXX do something"

				continue
			else:
				print _("    Solutions:")
				i = 0
				for solution in solutions:
					i += 1
					print "      #%d: %s" % (i, solution)

				print

		if not altered:
			return False

		# If the request was altered by the user, we try to solve it again
		# and see what happens.
		return self.solve(request, update=update, uninstall=uninstall,
			allow_downgrade=allow_downgrade, interactive=interactive)
コード例 #6
0
    def load_file(self):

        self.BZMAN_settings = read_file(self.ctx.get_settings_file)

        if self.BZMAN_settings['path'] == "":
            inform_user(
                self, "There is no database location specified.\n\n" +
                "If you haven't created a database, create a new database using 'New'\n\n"
                +
                "If you have recently moved the file to a new location, use the 'Set New Path' option in File menu to set the new file location"
            )

        else:
            try:
                # x = [os.path.abspath(f) for f in os.listdir(self.BZMAN_settings['path']) if os.path.isfile(f)]
                x = os.listdir(self.BZMAN_settings['path'])
                temp_list = []
                filename = None
                for i in range(len(x)):
                    if x[i].find("_BZMAN_DATABASE.json") != -1:
                        temp_list.append(x[i])

                if len(temp_list) > 1:
                    inform_user(
                        self,
                        "There are more than one database files. Please select the one you want to open"
                    )
                    filename = QFileDialog.getOpenFileName(
                        self,
                        "Open",
                        self.BZMAN_settings['path'],
                        filter="Database Files (*.json)")[0]

                elif len(temp_list) == 0:
                    ans = ask_user(
                        self, "No Company Database found! \n\n" +
                        "If you haven't created a company database yet, you can do it using 'New' option. Click 'Ok' to create a new database.\n\n"
                        +
                        "If you have already created a Database but moved it to a differenct location, please open it manually by clicking 'Cancel'."
                    )
                    if ans == QMessageBox.Ok:
                        self.new_file()
                    elif ans == QMessageBox.Cancel:
                        filename = QFileDialog.getOpenFileName(
                            self,
                            "Open",
                            self.BZMAN_settings['path'],
                            filter="Database Files (*.json)")[0]
                        if filename:
                            ans = ask_user(
                                self,
                                "Do you want to save this file location for future use? This will overwrite your existing path where the file wasn't found."
                            )

                            if ans == QMessageBox.Ok:
                                new_path, new_filename = os.path.split(
                                    filename)
                                new_company_name = " ".join(
                                    os.path.split(
                                        os.path.splitext(filename)[0])
                                    [1].split('_')[:-2])
                                self.BZMAN_settings['path'] = new_path
                                self.BZMAN_settings[
                                    'database_name'] = new_filename
                                self.BZMAN_settings[
                                    'company'] = new_company_name
                                write_file(self.BZMAN_settings,
                                           self.ctx.get_settings_file)

                    else:  #4194304
                        pass

                else:
                    filename = os.path.join(self.BZMAN_settings['path'] + '/' +
                                            temp_list[0])

                if filename:
                    self._open_main_window(filename)

            except OSError:  #TODO maybe set the file path to ""; if file can not be found
                inform_user(
                    self,
                    "The database folder has been moved or deleted! If moved, use 'Open' or 'Set New Path'"
                )
コード例 #7
0
ファイル: transaction.py プロジェクト: ipfire/pakfire
	def cli_yesno(self):
		# Empty transactions are always denied.
		if not self.steps:
			return False

		return util.ask_user(_("Is this okay?"))
コード例 #8
0
ファイル: transaction.py プロジェクト: pombredanne/pakfire
    def cli_yesno(self):
        # Empty transactions are always denied.
        if not self.steps:
            return False

        return util.ask_user(_("Is this okay?"))