예제 #1
0
 def chunk_thread(self):
     ratio = float(self.thread.chunk) / float(self.thread.chunks)
     percent = int(ratio * 10)
     leftover = 10 - percent
     message = "[" + "-" * percent + ">" + "-" * leftover + ("] %3d%%" % int(ratio * 100)) + " chunks hashed"
     sublime.status_message(message)
     if not self.thread.is_alive():
         if self.thread.abort is True:
             notify("Hash calculation aborted!")
             sublime.set_timeout(lambda: self.reset_thread(), 500)
         else:
             sublime.set_timeout(lambda: self.display(), 500)
     else:
         sublime.set_timeout(lambda: self.chunk_thread(), 500)
예제 #2
0
 def handle_thread(self):
     if self.abort is True:
         self.thread.abort = True
         notify("Hex View aborted!")
         sublime.set_timeout(lambda: self.reset_thread(), 500)
         return
     ratio = float(self.thread.read_count) / float(self.thread.file_size)
     percent = int(ratio * 10)
     leftover = 10 - percent
     message = "[" + "-" * percent + ">" + "-" * leftover + ("] %3d%%" % int(ratio * 100)) + " converted to hex"
     sublime.status_message(message)
     if not self.thread.is_alive():
         sublime.set_timeout(lambda: self.load_hex_view(), 100)
     else:
         sublime.set_timeout(lambda: self.handle_thread(), 100)
예제 #3
0
 def chunk_thread(self):
     ratio = float(self.thread.chunk) / float(self.thread.chunks)
     percent = int(ratio * 10)
     leftover = 10 - percent
     message = "[" + "-" * percent + ">" + "-" * leftover + (
         "] %3d%%" % int(ratio * 100)) + " chunks hashed"
     sublime.status_message(message)
     if not self.thread.is_alive():
         if self.thread.abort is True:
             notify("Hash calculation aborted!")
             sublime.set_timeout(lambda: self.reset_thread(), 500)
         else:
             sublime.set_timeout(lambda: self.display(), 500)
     else:
         sublime.set_timeout(lambda: self.chunk_thread(), 500)
예제 #4
0
 def handle_thread(self):
     if self.abort is True:
         self.thread.abort = True
         notify("Hex View aborted!")
         sublime.set_timeout(lambda: self.reset_thread(), 500)
         return
     ratio = float(self.thread.read_count) / float(self.thread.file_size)
     percent = int(ratio * 10)
     leftover = 10 - percent
     message = "[" + "-" * percent + ">" + "-" * leftover + (
         "] %3d%%" % int(ratio * 100)) + " converted to hex"
     sublime.status_message(message)
     if not self.thread.is_alive():
         sublime.set_timeout(lambda: self.load_hex_view(), 100)
     else:
         sublime.set_timeout(lambda: self.handle_thread(), 100)
예제 #5
0
    def chunk_thread(self):
        """Check how many chunks have been processed and update status."""

        ratio = float(self.thread.chunk) / float(self.thread.chunks)
        percent = int(ratio * 10)
        leftover = 10 - percent
        message = "[" + "-" * percent + ">" + "-" * leftover + ("] %3d%%" % int(ratio * 100)) + " chunks hashed"
        sublime.status_message(message)
        if not self.thread.is_alive():
            if self.thread.abort is True:
                notify("Hash calculation aborted!")
                sublime.set_timeout(self.reset_thread, 500)
            else:
                sublime.set_timeout(self.display, 500)
        else:
            sublime.set_timeout(self.chunk_thread, 500)
예제 #6
0
    def chunk_thread(self):
        """Check how many chunks have been processed and update status."""

        ratio = float(self.thread.chunk) / float(self.thread.chunks)
        percent = int(ratio * 10)
        leftover = 10 - percent
        message = "[" + "-" * percent + ">" + "-" * leftover + ("] %3d%%" % int(ratio * 100)) + " chunks hashed"
        sublime.status_message(message)
        if not self.thread.is_alive():
            if self.thread.abort is True:
                notify("Hash calculation aborted!")
                sublime.set_timeout(self.reset_thread, 500)
            else:
                sublime.set_timeout(self.display, 500)
        else:
            sublime.set_timeout(self.chunk_thread, 500)
예제 #7
0
    def load_hex_view(self):
        """Load up the hex view."""

        file_name = self.thread.file_name
        hex_name = self.thread.hex_name
        abort = self.thread.abort
        self.thread = None

        if abort:
            notify("Conversion aborted!")
            if exists(hex_name):
                remove(hex_name)
            return

        # Show binary data
        view = self.window.open_file(hex_name)

        if self.view:
            self.window.focus_view(self.view)
            if self.window.active_view().id() == self.view.id():
                self.window.run_command("close_file")
        else:
            self.window.focus_sheet(self.sheet)
            if self.window.active_sheet().id() == self.sheet.id():
                self.window.run_command("close_file")
        self.window.focus_view(view)

        # Set font
        if self.font != 'none':
            view.settings().set('font_face', self.font)
        if self.font_size != 0:
            view.settings().set("font_size", self.font_size)

        # Save hex view settings
        view.settings().set("hex_viewer_bits", self.bits)
        view.settings().set("hex_viewer_bytes", self.bytes)
        view.settings().set("hex_viewer_actual_bytes", self.bytes_wide)
        view.settings().set("hex_viewer_file_name", file_name)
        view.settings().set("hex_no_auto_open", True)
        view.settings().set("hex_viewer_fake", False)
        view.settings().set("hex_viewer_temp_file", hex_name)
        view.settings().set("hex_viewer_starting_address",
                            self.starting_address)
        # Show hex content in view; make read only
        view.set_scratch(True)
        view.set_read_only(True)
예제 #8
0
    def load_hex_view(self):
        """Load up the hex view."""

        file_name = self.thread.file_name
        hex_name = self.thread.hex_name
        abort = self.thread.abort
        self.thread = None

        if abort:
            notify("Conversion aborted!")
            if exists(hex_name):
                remove(hex_name)
            return

        # Show binary data
        view = self.window.open_file(hex_name)

        if self.view:
            self.window.focus_view(self.view)
            if self.window.active_view().id() == self.view.id():
                self.window.run_command("close_file")
        else:
            self.window.focus_sheet(self.sheet)
            if self.window.active_sheet().id() == self.sheet.id():
                self.window.run_command("close_file")
        self.window.focus_view(view)

        # Set font
        if self.font != 'none':
            view.settings().set('font_face', self.font)
        if self.font_size != 0:
            view.settings().set("font_size", self.font_size)

        # Save hex view settings
        view.settings().set("hex_viewer_bits", self.bits)
        view.settings().set("hex_viewer_bytes", self.bytes)
        view.settings().set("hex_viewer_actual_bytes", self.bytes_wide)
        view.settings().set("hex_viewer_file_name", file_name)
        view.settings().set("hex_no_auto_open", True)
        view.settings().set("hex_viewer_fake", False)
        view.settings().set("hex_viewer_temp_file", hex_name)
        view.settings().set("hex_viewer_starting_address", self.starting_address)
        # Show hex content in view; make read only
        view.set_scratch(True)
        view.set_read_only(True)
예제 #9
0
 def export_thread(self):
     ratio = float(self.thread.chunk) / float(self.thread.chunks)
     percent = int(ratio * 10)
     leftover = 10 - percent
     message = "[" + "-" * percent + ">" + "-" * leftover + (
         "] %3d%%" % int(ratio * 100)) + " chunks written"
     sublime.status_message(message)
     if not self.thread.is_alive():
         if self.thread.abort is True:
             notify("Write aborted!")
             sublime.set_timeout(lambda: self.reset_thread(), 500)
         else:
             status = self.thread.status
             self.reset_thread()
             if status == WRITE_GOOD:
                 sublime.set_timeout(lambda: self.finish_export(), 500)
             else:
                 error("Failed to export to " + self.export_path)
     else:
         sublime.set_timeout(lambda: self.export_thread(), 500)
예제 #10
0
    def export_thread(self):
        """Thread the export."""

        ratio = float(self.thread.chunk) / float(self.thread.chunks)
        percent = int(ratio * 10)
        leftover = 10 - percent
        message = "[" + "-" * percent + ">" + "-" * leftover + ("] %3d%%" % int(ratio * 100)) + " chunks written"
        sublime.status_message(message)
        if not self.thread.is_alive():
            if self.thread.abort is True:
                notify("Write aborted!")
                sublime.set_timeout(self.reset_thread, 500)
            else:
                status = self.thread.status
                self.reset_thread()
                if status == WRITE_GOOD:
                    sublime.set_timeout(self.finish_export, 500)
                else:
                    error("Failed to export to " + self.export_path)
        else:
            sublime.set_timeout(self.export_thread, 500)