Skip to content

Commit 1c5ac5f

Browse files
committed
command line exit node. pip install dev scripts
1 parent 98aa626 commit 1c5ac5f

File tree

9 files changed

+77
-8
lines changed

9 files changed

+77
-8
lines changed

PyFlow/Core/GraphManager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GraphManager(object):
3232
"""
3333
def __init__(self):
3434
super(GraphManager, self).__init__()
35+
self.terminationRequested = False #: used by cli only
3536
self.graphChanged = Signal(object)
3637
self._graphs = {}
3738
self._activeGraph = None

PyFlow/Core/NodeBase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ def initializeFromFunction(foo):
713713
"""
714714
retAnyOpts = None
715715
retConstraint = None
716-
foo = foo
717716
meta = foo.__annotations__['meta']
718717
returnType = returnDefaultValue = None
719718
returnPinOptionsToEnable = None
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Copyright 2015-2019 Ilgar Lunin, Pedro Cabrera
2+
3+
## Licensed under the Apache License, Version 2.0 (the "License");
4+
## you may not use this file except in compliance with the License.
5+
## You may obtain a copy of the License at
6+
7+
## http://www.apache.org/licenses/LICENSE-2.0
8+
9+
## Unless required by applicable law or agreed to in writing, software
10+
## distributed under the License is distributed on an "AS IS" BASIS,
11+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
## See the License for the specific language governing permissions and
13+
## limitations under the License.
14+
15+
16+
from PyFlow.Core import NodeBase
17+
from PyFlow.Core.Common import *
18+
from PyFlow.Core.GraphManager import GraphManagerSingleton
19+
from PyFlow.Core.NodeBase import NodePinsSuggestionsHelper
20+
from PyFlow.Packages.PyFlowBase.Nodes import FLOW_CONTROL_COLOR
21+
22+
23+
class cliexit(NodeBase):
24+
def __init__(self, name):
25+
super(cliexit, self).__init__(name)
26+
self.inp0 = self.createInputPin(DEFAULT_IN_EXEC_NAME, 'ExecPin', None, self.compute)
27+
28+
@staticmethod
29+
def pinTypeHints():
30+
helper = NodePinsSuggestionsHelper()
31+
helper.addInputDataType('ExecPin')
32+
helper.addInputStruct(PinStructure.Single)
33+
return helper
34+
35+
@staticmethod
36+
def category():
37+
return 'CLI'
38+
39+
@staticmethod
40+
def keywords():
41+
return []
42+
43+
@staticmethod
44+
def description():
45+
return 'Stops cli program loop'
46+
47+
def compute(self, *args, **kwargs):
48+
man = GraphManagerSingleton().get()
49+
man.terminationRequested = True

PyFlow/Packages/PyFlowBase/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from PyFlow.Packages.PyFlowBase.Nodes.floatRamp import floatRamp
5555
from PyFlow.Packages.PyFlowBase.Nodes.colorRamp import colorRamp
5656
from PyFlow.Packages.PyFlowBase.Nodes.stringToArray import stringToArray
57+
from PyFlow.Packages.PyFlowBase.Nodes.cliexit import cliexit
5758

5859

5960
from PyFlow.Packages.PyFlowBase.Nodes.consoleOutput import consoleOutput
@@ -148,7 +149,8 @@
148149
floatRamp.__name__: floatRamp,
149150
colorRamp.__name__: colorRamp,
150151
stringToArray.__name__: stringToArray,
151-
imageDisplay.__name__: imageDisplay
152+
imageDisplay.__name__: imageDisplay,
153+
cliexit.__name__: cliexit
152154
}
153155

154156
_PINS = {

PyFlow/Scripts/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
import sys
1818
import os
1919
import json
20+
import threading
21+
import time
22+
2023
from PyFlow.App import PyFlow
2124
from PyFlow import graphUiParser
2225
from Qt.QtWidgets import QApplication
2326
from PyFlow import INITIALIZE
2427
from PyFlow.Core.Common import *
2528
from PyFlow.Core.version import currentVersion
26-
from PyFlow.Core.GraphManager import GraphManager
29+
from PyFlow.Core.GraphManager import GraphManagerSingleton
2730

2831

2932
def getGraphArguments(data, parser):
@@ -76,6 +79,7 @@ def main():
7679
with open(filePath, 'r') as f:
7780
data = json.load(f)
7881
instance.loadFromData(data)
82+
instance.currentFileName = filePath
7983

8084
try:
8185
sys.exit(app.exec_())
@@ -91,9 +95,17 @@ def main():
9195

9296
# load updated data
9397
INITIALIZE()
94-
GM = GraphManager()
98+
GM = GraphManagerSingleton().get()
9599
GM.deserialize(data)
96100

101+
# fake main loop
102+
def programLoop():
103+
while True:
104+
GM.Tick(deltaTime=0.02)
105+
time.sleep(0.02)
106+
if GM.terminationRequested:
107+
break
108+
97109
# call graph inputs nodes
98110
root = GM.findRootGraph()
99111
graphInputNodes = root.getNodesList(classNameFilters=["graphInputs"])
@@ -111,5 +123,9 @@ def main():
111123
for foo in evalFunctions:
112124
foo()
113125

126+
loopThread = threading.Thread(target=programLoop)
127+
loopThread.start()
128+
loopThread.join()
129+
114130
if parsedArguments.mode == "runui":
115131
graphUiParser.run(filePath)

PyFlow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def recursePackagePaths(inPath):
162162
additionalPackageLocations[packagePathId] = packagePath
163163

164164
packagePaths.extend(additionalPackageLocations)
165-
165+
166166
for importer, modname, ispkg in pkgutil.iter_modules(packagePaths):
167167
try:
168168
if ispkg:

PyFlow/graphUiParser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@ def run(filePath):
6868

6969
# fake main loop
7070
stopEvent = threading.Event()
71+
7172
def programLoop(stopEvent):
7273
while not stopEvent.is_set():
7374
man.Tick(deltaTime=0.02)
7475
time.sleep(0.02)
7576
t = threading.Thread(target=programLoop, args=(stopEvent,))
7677
t.start()
78+
7779
def quitEvent():
7880
stopEvent.set()
7981
t.join()
8082
app.aboutToQuit.connect(quitEvent)
8183
else:
82-
8384
msg.setInformativeText(filePath)
84-
msg.setDetailedText(
85-
"The file doesn't containt graphInputs nodes")
85+
msg.setDetailedText("The file doesn't containt graphInputs nodes")
8686
msg.setWindowTitle("PyFlow Ui Graph Parser")
8787
msg.setStandardButtons(QMessageBox.Ok)
8888
msg.show()

pip_install.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip install . -U

pip_uninstall.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip uninstall pyflow

0 commit comments

Comments
 (0)