1 from PyQt5
import QtGui, QtCore, QtWidgets
7 usage=
'''The DNG application bundle contains two shell commands ('ost' and 'dng') that lets you use the OpenStructure command-line interpreter and dng from the terminal. If you want to use these commands, it is recommended that a symbolic link is created.
11 QtWidgets.QDialog.__init__(self, parent)
12 self.setWindowTitle(
'Enhanced Terminal Usage')
13 self.setFixedSize(QSize(480, 300))
15 title=QLabel(
'Enhanced Terminal Usage')
23 l2.addWidget(QLabel(
'If you proceed, the link will be created in: '))
25 self.path_combo.setFixedWidth(150)
26 for path
in os.getenv(
'PATH').split(
':'):
27 exp_path=os.path.expanduser(path)
28 if os.path.exists(exp_path)
and exp_path.find(
'DNG.app')==-1:
29 self.path_combo.addItem(path)
33 ab=QPushButton(
'Create Link')
35 cb=QPushButton(
'Don\'t Create')
40 text.setWordWrap(
True)
41 QObject.connect(cb, SIGNAL(
'clicked()'), self.reject)
42 QObject.connect(ab, SIGNAL(
'clicked()'), self.accept)
44 return str(self.path_combo.currentText())
46 def _CreateLinks(bin_dir, sel_dir):
47 for bin
in (
'ost',
'dng',
'lddt',
'chemdict_tool'):
48 if os.path.exists(os.path.join(sel_dir, bin)):
49 os.unlink(os.path.join(sel_dir, bin))
50 os.system(
'ln -s "%s" "%s"' % (os.path.join(bin_dir, bin),
51 os.path.join(sel_dir, bin)))
54 Installs symlinks to the 'ost' and 'dng' command line programs into a
55 user-specified directory in the path.
60 bin_dir=os.path.join(prefix,
'bin')
61 sel_path=term_use.GetSelectedPath()
62 if not os.access(sel_path, os.W_OK):
64 if admin_rights.Acquire():
65 for bin
in (
'ost',
'dng',
'lddt',
'chemdict_tool'):
66 admin_rights.CreateLink(os.path.join(bin_dir, bin),
67 os.path.join(sel_path, bin))
68 admin_rights.Release()
70 _CreateLinks(bin_dir, sel_path)
String DLLEXPORT_OST_BASE GetPrefixPath()
get the path prefix
def InstallTerminalPrograms