forked from ctrl_packages/epics_launcher
COSYLAB-360 packagin as anaconda package + some minor things
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"Linux": {
|
||||
"theme_base": "./qss/",
|
||||
"theme_base": "../qss",
|
||||
"cmd": {
|
||||
"command": ""
|
||||
},
|
||||
@@ -9,6 +9,8 @@ import json
|
||||
import copy
|
||||
import enum
|
||||
import urllib2
|
||||
import urlparse
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from PyQt4.QtCore import pyqtSlot, Qt
|
||||
@@ -38,9 +40,10 @@ class LauncherWindow(QtGui.QMainWindow):
|
||||
try:
|
||||
cfgFile = open_launcher_file(cfgFilePath)
|
||||
except IOError:
|
||||
errMsg = "Err: Configuration file \"" + cfgFilePath + \
|
||||
errMsg = "Configuration file \"" + cfgFilePath + \
|
||||
"\" not found."
|
||||
sys.exit(errMsg)
|
||||
logging.error(errMsg)
|
||||
sys.exit()
|
||||
cfg = json.load(cfgFile)
|
||||
cfgFile.close()
|
||||
# Get configuration for current system. platform.system() returns:
|
||||
@@ -57,6 +60,8 @@ class LauncherWindow(QtGui.QMainWindow):
|
||||
path_tuple = os.path.split(rootFilePath)
|
||||
self.launcherCfg["launcher_base"] = path_tuple[0]
|
||||
rootFilePath = path_tuple[1]
|
||||
# Get defined theme base. If it is not url or absolute dir, make it
|
||||
# relative to config file.
|
||||
|
||||
self.menuModel = self.buildMenuModel(rootFilePath)
|
||||
self.setWindowTitle(self.menuModel.mainTitle)
|
||||
@@ -122,8 +127,9 @@ class LauncherWindow(QtGui.QMainWindow):
|
||||
try:
|
||||
rootMenuFile = open_launcher_file(rootMeniFullPath)
|
||||
except IOError:
|
||||
errMsg = "Err: File \"" + rootMenuPath + "\" not found."
|
||||
sys.exit(errMsg)
|
||||
errMsg = "File \"" + rootMenuPath + "\" not found."
|
||||
logging.error(errMsg)
|
||||
sys.exit()
|
||||
rootMenu = launcher_menu_model(None, rootMenuFile, 0, self.launcherCfg)
|
||||
rootMenuFile.close()
|
||||
return rootMenu
|
||||
@@ -445,6 +451,7 @@ class LauncherSearchMenuView(LauncherMenu):
|
||||
addPrefix = True
|
||||
elif item.__class__.__name__ == "launcher_sub_menu_item":
|
||||
# Take subemnu model and build (visualize) it below
|
||||
|
||||
cSubMenuItems = copy.copy(item.sub_menu.menu_items)
|
||||
cMenuItems.extend(cSubMenuItems)
|
||||
elif item.__class__.__name__ == "launcher_title_item":
|
||||
@@ -982,11 +989,17 @@ class LauncherStyle:
|
||||
|
||||
def appendThemeStyle(self, theme):
|
||||
mainWindow = self.item.parent().getLauncherWindow()
|
||||
theme_file = open_launcher_file(
|
||||
mainWindow.launcherCfg.get("theme_base") + theme + ".qss")
|
||||
self.styleString = self.styleString + theme_file.read()
|
||||
theme_file.close()
|
||||
self.style = QtCore.QLatin1String(self.styleString)
|
||||
try:
|
||||
theme_file = open_launcher_file(
|
||||
os.path.join(mainWindow.launcherCfg.get("theme_base"),
|
||||
theme + ".qss"))
|
||||
self.styleString = self.styleString + theme_file.read()
|
||||
theme_file.close()
|
||||
self.style = QtCore.QLatin1String(self.styleString)
|
||||
except IOError:
|
||||
warnMsg = "Theme \"" + theme + \
|
||||
"\" was not found. Theme ignored."
|
||||
logging.warning(warnMsg)
|
||||
|
||||
def appendStyle(self, style, item):
|
||||
self.styleString = self.styleString + item.__class__.__name__ +\
|
||||
@@ -997,8 +1010,8 @@ class LauncherStyle:
|
||||
self.styleString = self.styleString + style
|
||||
self.style = QtCore.QLatin1String(self.styleString)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
def main():
|
||||
# Usage: launcher.py menu config
|
||||
argsPars = argparse.ArgumentParser()
|
||||
argsPars.add_argument('config',
|
||||
@@ -1014,8 +1027,9 @@ if __name__ == '__main__':
|
||||
|
||||
app.setStyle("cleanlooks")
|
||||
currDir = os.path.dirname(os.path.realpath(__file__))
|
||||
print currDir
|
||||
styleFile = open_launcher_file(os.path.join(currDir,
|
||||
"res/qss/default.qss"))
|
||||
"res/qss/default.qss"))
|
||||
app.setStyleSheet(styleFile.read())
|
||||
styleFile.close()
|
||||
launcherWindow = LauncherWindow(args.launcher, args.config)
|
||||
@@ -1025,9 +1039,13 @@ if __name__ == '__main__':
|
||||
launcherWindow.setStyleSheet(userStyle.read())
|
||||
userStyle.close()
|
||||
except IOError:
|
||||
errMsg = "Err: Style file \"" + args.style + "\" not found."
|
||||
sys.exit(errMsg)
|
||||
errMsg = "Style file \"" + args.style + "\" not found."
|
||||
logging.error(errMsg)
|
||||
sys.exit()
|
||||
|
||||
launcherWindow.setGeometry(0, 0, 150, 0)
|
||||
launcherWindow.show()
|
||||
sys.exit(app.exec_())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Binary file not shown.
@@ -75,17 +75,18 @@ class launcher_menu_model:
|
||||
text,
|
||||
file_name))
|
||||
except IOError:
|
||||
err_msg = "ParseErr: " + menu_file.geturl() + ": File \"" +\
|
||||
file_name + "\" not found."
|
||||
logging.warning(err_msg)
|
||||
warn_msg = "Parser: " + menu_file.geturl() + ": File \"" +\
|
||||
file_name + "\" not found. Skipped"
|
||||
logging.warning(warn_msg)
|
||||
|
||||
# Build menu model. Report error if menu is not defined.
|
||||
|
||||
list_of_menu_items = menu.get("menu", list())
|
||||
if not list_of_menu_items:
|
||||
err_msg = "ParseErr: " + menu_file.geturl() +\
|
||||
": Launcher menu is not defined."
|
||||
sys.exit(err_msg)
|
||||
err_msg = "Parser: " + menu_file.geturl() +\
|
||||
": Launcher menu is empty."
|
||||
logging.error(err_msg)
|
||||
sys.exit()
|
||||
|
||||
for item in list_of_menu_items:
|
||||
menu_item = None
|
||||
@@ -140,9 +141,9 @@ class launcher_menu_model:
|
||||
None)
|
||||
sub_file.close()
|
||||
except IOError:
|
||||
err_msg = "ParseErr: " + menu_file.geturl() + \
|
||||
": File \"" + file_name + "\" not found."
|
||||
logging.warning(err_msg)
|
||||
warn_msg = "Parser: " + menu_file.geturl() + \
|
||||
": File \"" + file_name + "\" not found. Skipped"
|
||||
logging.warning(warn_msg)
|
||||
|
||||
elif item_type == "title":
|
||||
self.check_item_format_json(item, ["text"])
|
||||
@@ -153,9 +154,9 @@ class launcher_menu_model:
|
||||
menu_item = launcher_item_separator(self, theme, style)
|
||||
|
||||
else:
|
||||
err_msg = "ParseErr:" + menu_file.geturl() + \
|
||||
": Unknown type \"" + item_type + "\"."
|
||||
logging.warning(err_msg)
|
||||
warn_msg = "Parser:" + menu_file.geturl() + \
|
||||
": Unknown type \"" + item_type + "\". Skipped"
|
||||
logging.warning(warn_msg)
|
||||
|
||||
if menu_item != None:
|
||||
self.menu_items.append(menu_item)
|
||||
@@ -169,9 +170,10 @@ class launcher_menu_model:
|
||||
|
||||
for param in mandatory_param:
|
||||
if not item.get(param):
|
||||
err_msg = "ParseErr: Parameter \"" + param + \
|
||||
err_msg = "Parser Parameter \"" + param + \
|
||||
"\" is mandatory in configuration \"" + item + "\"."
|
||||
sys.exit(err_msg)
|
||||
logging.error(err_msg)
|
||||
sys.exit()
|
||||
|
||||
|
||||
class launcher_menu_model_item:
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 223 B |
|
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
Binary file not shown.
@@ -6,28 +6,26 @@ from setuptools import setup, find_packages
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
README = open(os.path.join(here, 'Readme.md')).read()
|
||||
|
||||
version = '1.0.00'
|
||||
setup(name='pylauncher',
|
||||
version=version,
|
||||
version='1.0.00',
|
||||
description="Standard PSI tool for accessing GUIs",
|
||||
long_description=README,
|
||||
author='PSI',
|
||||
url='https://github.psi.ch/projects/COS/repos/pylauncher/browse',
|
||||
licence='GPLv3+',
|
||||
keywords='launcher, caqtdm, medm, PSI',
|
||||
classifiers=[
|
||||
# Get strings from
|
||||
# http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: Console',
|
||||
'Intended Audience :: Developers',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||
'Topic :: Software Development :: Testing',
|
||||
'Topic :: Utilities',
|
||||
'License :: OSI Approved :: MIT License'
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)'
|
||||
],
|
||||
keywords='launcher, caqtdm, medm, PSI',
|
||||
author='PSI',
|
||||
url='https://github.psi.ch/projects/COS/repos/pylauncher/browse',
|
||||
license='MIT License',
|
||||
packages=find_packages(exclude=['*.tests']),
|
||||
#packages=find_packages(exclude=['*.tests']),
|
||||
packages=['pylauncher'],
|
||||
package_dir={'pylauncher': 'pylauncher'},
|
||||
package_data={'pylauncher': ['res/images/*.png', 'res/qss/*.qss']},
|
||||
platforms=["any"],
|
||||
)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
"%PYTHON%" setup.py install
|
||||
if errorlevel 1 exit 1
|
||||
@@ -0,0 +1 @@
|
||||
$PYTHON setup.py install # Python command to install the script
|
||||
@@ -0,0 +1,20 @@
|
||||
package:
|
||||
name: pylauncher
|
||||
version: 1.0.0
|
||||
source:
|
||||
git_url: file:///home/rvintar/workspace/CSL/launcher_req/git/pylauncher
|
||||
build:
|
||||
entry_points:
|
||||
- pylauncher = pylauncher.launcher:main
|
||||
requirements:
|
||||
build:
|
||||
- python
|
||||
- setuptools
|
||||
- pyqt
|
||||
run:
|
||||
- python
|
||||
- pyqt
|
||||
about:
|
||||
home: https://github.psi.ch/projects/COS/repos/pylauncher/browse
|
||||
license: MIT
|
||||
summary: "Standard PSI launcher application."
|
||||
Reference in New Issue
Block a user