Initial open support in pytomb/gui

This commit is contained in:
boyska 2012-01-24 01:18:34 +01:00
parent 72b44a84f6
commit 9318377aca
3 changed files with 36 additions and 11 deletions

View File

@ -47,7 +47,8 @@ class Tomb(object):
return True
@classmethod
def create(cls, tombpath, tombsize,keypath, stdout=None, stderr=None, no_color=True, ignore_swap=False):
def create(cls, tombpath, tombsize,keypath, stdout=None, stderr=None,
no_color=True, ignore_swap=False):
'''If keypath is None, it will be created adjacent to the tomb.
This is unsafe, and you should NOT do it.
@ -69,9 +70,20 @@ class Tomb(object):
return False
return True
@staticmethod
def open(tombpath,keypath=None):
raise NotImplementedError
@classmethod
def open(cls, tombpath,keypath=None, no_color=True, ignore_swap=False):
args = [tombpath]
if keypath is not None:
args += ['-k', keypath]
if no_color:
args += ['--no-color']
if ignore_swap:
args += ['--ignore-swap']
try:
subprocess.check_call([cls.tombexec, 'open'] + args)
except subprocess.CalledProcessError:
return False
return True
if __name__ == '__main__':

View File

@ -1,10 +1,23 @@
all: ui_create.py
test: ui_create.py
python2 -3 create.py
ui_create.py: create.ui
pyuic4 create.ui -o ui_create.py
TARGETS_OPEN=tombqt/ui_open_tombfile.py tombqt/ui_open_keymethod.py tombqt/ui_open_success.py
TARGETS=tombqt/ui_create.py $(TARGETS_OPEN)
all: $(TARGETS)
test_create: tombqt/ui_create.py
python2 -3 tombqt/create.py
test_open: $(TARGETS_OPEN)
python2 -3 tombqt/open.py
tombqt/ui_create.py: tombqt/create.ui
pyuic4 create.ui -o tombqt/ui_create.py
tombqt/ui_open_tombfile.py: tombqt/open_tombfile.ui
pyuic4 tombqt/open_tombfile.ui -o tombqt/ui_open_tombfile.py
tombqt/ui_open_keymethod.py: tombqt/open_keymethod.ui
pyuic4 tombqt/open_keymethod.ui -o tombqt/ui_open_keymethod.py
tombqt/ui_open_success.py: tombqt/open_success.ui
pyuic4 tombqt/open_success.ui -o tombqt/ui_open_success.py
clean:
rm ui_create.py
rm $(TARGETS)
.PHONY: test clean

View File

@ -73,7 +73,7 @@ class TombCreateWizard(QWizard):
def on_tomb_location_clicked(self, *args, **kwargs):
filename = QtGui.QFileDialog.getSaveFileName(self, 'Create Tomb',
filter="*.tomb")
filter="Tomb(*.tomb)")
self.ui.lineEdit_tombpath.setText(filename)
def on_change_page(self, pagenumber):
if self.currentPage() == self.ui.wizardPage_progress: