Пример #1
0
    def set_file_metadata(self, bucket_id, file_id):
        try:
            file_metadata = self.storj_engine.storj_client.file_metadata(
                str(bucket_id), str(file_id))
            self.ui_single_file_download.file_name.setText(
                html_format_begin + str(file_metadata.filename) +
                html_format_end)

            tools = Tools()
            self.ui_single_file_download.file_size.setText(
                html_format_begin +
                str(tools.human_size(int(file_metadata.size))) +
                html_format_end)
            self.ui_single_file_download.file_id.setText(html_format_begin +
                                                         str(file_id) +
                                                         html_format_end)

            self.ui_single_file_download.file_save_path.setText(
                str(tools.get_home_user_directory() + "/" +
                    str(file_metadata.filename)))
        except storj.exception.StorjBridgeApiError as e:
            self.emit(QtCore.SIGNAL("showStorjBridgeException"),
                      "Error while resolving file metadata. " +
                      str(e))  # emit Storj Bridge Exception
        except Exception as e:
            self.emit(QtCore.SIGNAL("showUnhandledException"),
                      "Unhandled error while resolving file metadata. " +
                      str(e))  # emit unhandled Exception
Пример #2
0
    def set_file_metadata(self, bucket_id, file_id):
        try:
            self.emit(QtCore.SIGNAL("setCurrentState"),
                      "Getting file metadata...")
            file_metadata = self.storj_engine.storj_client.file_metadata(
                str(bucket_id), str(file_id))
            self.ui_single_file_download.file_name.setText(
                str(file_metadata.filename.replace("[DECRYPTED]",
                                                   "")).decode('utf-8'))

            tools = Tools()
            # self.ui_single_file_download.file_size.setText(
            #   html_format_begin + str(tools.human_size(int(file_metadata.size))) + html_format_end)
            self.ui_single_file_download.file_id.setText(str(file_id))

            if platform == "linux" or platform == "linux2":
                # linux
                self.ui_single_file_download.file_save_path.setText(
                    str(tools.get_home_user_directory() + "/" +
                        str(file_metadata.filename.replace("[DECRYPTED]", ""))
                        ).decode('utf-8'))
            elif platform == "darwin":
                # OS X
                self.ui_single_file_download.file_save_path.setText(
                    str(tools.get_home_user_directory() + "/" +
                        str(file_metadata.filename.replace("[DECRYPTED]", ""))
                        ).decode('utf-8'))
            elif platform == "win32":
                self.ui_single_file_download.file_save_path.setText(
                    str(tools.get_home_user_directory() + "\\" +
                        str(file_metadata.filename.replace("[DECRYPTED]", ""))
                        ).decode('utf-8'))

            self.filename_from_bridge = str(file_metadata.filename)

            self.resolved_file_metadata = True
            self.emit(QtCore.SIGNAL("setCurrentState"),
                      "Waiting for user action...")

        except storj.exception.StorjBridgeApiError as e:
            self.emit(QtCore.SIGNAL("showStorjBridgeException"),
                      "Error while resolving file metadata. " +
                      str(e))  # emit Storj Bridge Exception
        except Exception as e:
            self.emit(QtCore.SIGNAL("showUnhandledException"),
                      "Unhandled error while resolving file metadata. " +
                      str(e))  # emit unhandled Exception