Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020_068
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020_068
2020_068
Commits
3c82ef41
Commit
3c82ef41
authored
Nov 05, 2020
by
Tharindu Munasinghe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workstation handler
parent
a1ddb488
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
0 deletions
+150
-0
RenderH/SlaveAssignment.py
RenderH/SlaveAssignment.py
+150
-0
No files found.
RenderH/SlaveAssignment.py
0 → 100644
View file @
3c82ef41
try
:
from
PySide.QtCore
import
*
from
PySide.QtGui
import
*
psVersion
=
1
except
:
from
PySide2.QtCore
import
*
from
PySide2.QtGui
import
*
from
PySide2.QtWidgets
import
*
psVersion
=
2
import
sys
,
os
,
traceback
,
time
,
socket
from
functools
import
wraps
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"UserInterfacesPandora"
))
try
:
del
sys
.
modules
[
"PandoraSlaveAssignment_ui"
]
except
:
pass
if
psVersion
==
1
:
import
PandoraSlaveAssignment_ui
else
:
import
PandoraSlaveAssignment_ui_ps2
as
PandoraSlaveAssignment_ui
class
PandoraSlaveAssignment
(
QDialog
,
PandoraSlaveAssignment_ui
.
Ui_dlg_SlaveAssignment
):
def
__init__
(
self
,
core
,
curSlaves
=
""
):
QDialog
.
__init__
(
self
)
self
.
setupUi
(
self
)
self
.
core
=
core
self
.
core
.
parentWindow
(
self
)
self
.
slaveGroups
=
[]
self
.
activeGroups
=
[]
self
.
getSlaves
()
self
.
connectEvents
()
if
curSlaves
.
startswith
(
"exclude "
):
self
.
rb_exclude
.
setChecked
(
True
)
curSlaves
=
curSlaves
[
len
(
"exclude "
):]
if
curSlaves
==
"All"
:
self
.
rb_all
.
setChecked
(
True
)
self
.
lw_slaves
.
selectAll
()
elif
curSlaves
.
startswith
(
"groups: "
):
groupList
=
curSlaves
[
len
(
"groups: "
):]
.
split
(
", "
)
for
i
in
self
.
slaveGroups
:
if
i
.
text
()
in
groupList
:
i
.
setChecked
(
True
)
self
.
rb_group
.
setChecked
(
True
)
elif
curSlaves
!=
""
:
slaveList
=
curSlaves
.
split
(
", "
)
for
i
in
range
(
self
.
lw_slaves
.
count
()):
item
=
self
.
lw_slaves
.
item
(
i
)
if
item
.
text
()
in
slaveList
:
self
.
lw_slaves
.
setCurrentItem
(
item
,
QItemSelectionModel
.
Select
)
self
.
rb_custom
.
setChecked
(
True
)
else
:
self
.
rb_custom
.
setChecked
(
True
)
def
err_decorator
(
func
):
@
wraps
(
func
)
def
func_wrapper
(
*
args
,
**
kwargs
):
try
:
return
func
(
*
args
,
**
kwargs
)
except
Exception
as
e
:
exc_type
,
exc_obj
,
exc_tb
=
sys
.
exc_info
()
erStr
=
(
"
%
s ERROR - PandoraSlaveAssignment
%
s:
\n
%
s
\n\n
%
s"
%
(
time
.
strftime
(
"
%
d/
%
m/
%
y
%
X"
),
args
[
0
]
.
core
.
version
,
''
.
join
(
traceback
.
format_stack
()),
traceback
.
format_exc
()))
args
[
0
]
.
core
.
writeErrorLog
(
erStr
)
return
func_wrapper
@
err_decorator
def
connectEvents
(
self
):
self
.
lw_slaves
.
itemSelectionChanged
.
connect
(
self
.
selectionChanged
)
self
.
lw_slaves
.
itemDoubleClicked
.
connect
(
self
.
accept
)
self
.
rb_all
.
clicked
.
connect
(
lambda
:
self
.
optionChanged
(
"all"
))
self
.
rb_group
.
clicked
.
connect
(
lambda
:
self
.
optionChanged
(
"group"
))
self
.
rb_custom
.
clicked
.
connect
(
lambda
:
self
.
optionChanged
(
"custom"
))
@
err_decorator
def
getSlaves
(
self
):
self
.
lw_slaves
.
clear
()
slaveData
=
self
.
core
.
getSlaveData
()
gLayout
=
QVBoxLayout
()
self
.
w_slaveGroups
.
setLayout
(
gLayout
)
for
i
in
slaveData
[
"slaveNames"
]:
sItem
=
QListWidgetItem
(
i
)
self
.
lw_slaves
.
addItem
(
sItem
)
for
i
in
slaveData
[
"slaveGroups"
]:
chbGroup
=
QCheckBox
(
i
)
chbGroup
.
toggled
.
connect
(
self
.
groupToogled
)
gLayout
.
addWidget
(
chbGroup
)
self
.
slaveGroups
.
append
(
chbGroup
)
@
err_decorator
def
selectionChanged
(
self
):
if
len
(
self
.
lw_slaves
.
selectedItems
())
==
self
.
lw_slaves
.
count
()
and
self
.
rb_all
.
isChecked
():
return
self
.
rb_custom
.
setChecked
(
True
)
@
err_decorator
def
optionChanged
(
self
,
option
):
if
option
==
"all"
:
self
.
lw_slaves
.
selectAll
()
elif
option
==
"group"
:
self
.
selectGroups
()
@
err_decorator
def
groupToogled
(
self
,
checked
=
False
):
self
.
activeGroups
=
[]
for
i
in
self
.
slaveGroups
:
if
i
.
isChecked
():
self
.
activeGroups
.
append
(
i
.
text
())
if
len
(
self
.
activeGroups
)
>
0
:
self
.
selectGroups
()
else
:
self
.
lw_slaves
.
clearSelection
()
self
.
rb_group
.
setChecked
(
True
)
@
err_decorator
def
selectGroups
(
self
):
self
.
lw_slaves
.
clearSelection
()
if
len
(
self
.
activeGroups
)
>
0
:
for
i
in
range
(
self
.
lw_slaves
.
count
()):
sGroups
=
self
.
lw_slaves
.
item
(
i
)
.
toolTip
()
.
split
(
", "
)
for
k
in
self
.
activeGroups
:
if
k
not
in
sGroups
:
break
else
:
self
.
lw_slaves
.
setCurrentRow
(
i
,
QItemSelectionModel
.
Select
)
self
.
rb_group
.
setChecked
(
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment