コード例 #1
0
    def setup_method(self, method):
        self.main_window = MainWindow(None, -1)
        self.grid = self.main_window.grid
        self.code_array = self.grid.code_array

        # Filenames
        # ---------

        # File with valid signature
        self.filename_valid_sig = TESTPATH + "test1.pys"
        sign(self.filename_valid_sig)

        # File without signature
        self.filename_no_sig = TESTPATH + "test2.pys"

        # File with invalid signature
        self.filename_invalid_sig = TESTPATH + "test3.pys"

        # File for self.grid size test
        self.filename_gridsize = TESTPATH + "test4.pys"
        sign(self.filename_gridsize)

        # Empty file
        self.filename_empty = TESTPATH + "test5.pys"

        # File name that cannot be accessed
        self.filename_not_permitted = TESTPATH + "test6.pys"

        # File name without file
        self.filename_wrong = TESTPATH + "test-1.pys"

        # File for testing save
        self.filename_save = TESTPATH + "test_save.pys"
コード例 #2
0
def _set_sig(filename, sigfilename):
    """Creates a signature sigfilename for file filename"""

    signature = gpg.sign(filename).data

    with open(sigfilename, "w") as sigfile:
        sigfile.write(signature)
コード例 #3
0
ファイル: test_gpg.py プロジェクト: 01-/pyspread
def _set_sig(filename, sigfilename):
    """Creates a signature sigfilename for file filename"""

    signature = gpg.sign(filename).data

    with open(sigfilename, "w") as sigfile:
        sigfile.write(signature)
コード例 #4
0
    def sign_file(self, filepath):
        """Signs file if possible"""

        signature = sign(filepath)
        if signature is None:
            statustext = _('Error signing file. File is not signed.')
            try:
                post_command_event(self.main_window, self.StatusBarMsg,
                                   text=statustext)
            except TypeError:
                # The main window does not exist any more
                pass

            return

        signfile = open(filepath + '.sig', 'wb')
        signfile.write(signature)
        signfile.close()

        # Statustext differs if a save has occurred

        if self.code_array.safe_mode:
            statustext = _('File saved and signed')
        else:
            statustext = _('File signed')

        try:
            post_command_event(self.main_window, self.StatusBarMsg,
                           text=statustext)
        except TypeError:
            # The main window does not exist any more
            pass
コード例 #5
0
ファイル: test_gpg.py プロジェクト: sandeep-datta/pyspread
def _set_sig(filename, sigfilename):
    """Creates a signature sigfilename for file filename"""

    signature = gpg.sign(filename)

    sigfile = open(sigfilename, "w")
    sigfile.write(signature)
    sigfile.close()
コード例 #6
0
def _set_sig(filename, sigfilename):
    """Creates a signature sigfilename for file filename"""

    signature = gpg.sign(filename).data

    sigfile = open(sigfilename, "w")
    sigfile.write(signature)
    sigfile.close()
コード例 #7
0
    def sign_file(self, filepath):
        """Signs file if possible"""

        if not GPG_PRESENT:
            return

        signed_data = sign(filepath)
        signature = signed_data.data

        if signature is None or not signature:
            statustext = _('Error signing file. ') + signed_data.stderr
            try:
                post_command_event(self.main_window,
                                   self.StatusBarMsg,
                                   text=statustext)
            except TypeError:
                # The main window does not exist any more
                pass

            return

        with open(filepath + '.sig', 'wb') as signfile:
            signfile.write(signature)

        # Statustext differs if a save has occurred

        if self.code_array.safe_mode:
            statustext = _('File saved and signed')
        else:
            statustext = _('File signed')

        try:
            post_command_event(self.main_window,
                               self.StatusBarMsg,
                               text=statustext)
        except TypeError:
            # The main window does not exist any more
            pass
コード例 #8
0
ファイル: _grid_actions.py プロジェクト: jean/pyspread
    def sign_file(self, filepath):
        """Signs file if possible"""

        if not GPG_PRESENT:
            return

        signed_data = sign(filepath)
        signature = signed_data.data

        if signature is None or not signature:
            statustext = _('Error signing file. ') + signed_data.stderr
            try:
                post_command_event(self.main_window, self.StatusBarMsg,
                                   text=statustext)
            except TypeError:
                # The main window does not exist any more
                pass

            return

        with open(filepath + '.sig', 'wb') as signfile:
            signfile.write(signature)

        # Statustext differs if a save has occurred

        if self.code_array.safe_mode:
            statustext = _('File saved and signed')
        else:
            statustext = _('File signed')

        try:
            post_command_event(self.main_window, self.StatusBarMsg,
                               text=statustext)
        except TypeError:
            # The main window does not exist any more
            pass