[bin] use sys.exit + build meshroom_compute executable

* cx_Freeze removes builtin 'exit' function, use sys.exit in executables instead
* build: generate an executable for "meshroom_compute"
This commit is contained in:
Yann Lanthony 2019-02-27 15:00:16 +01:00
parent 569424274b
commit b147788e5c
6 changed files with 20 additions and 11 deletions

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import argparse import argparse
import sys
import meshroom import meshroom
meshroom.setupEnvironment() meshroom.setupEnvironment()
@ -47,7 +48,7 @@ if args.node:
for chunk in chunks: for chunk in chunks:
if chunk.status.status in submittedStatuses: if chunk.status.status in submittedStatuses:
print('Error: Node is already submitted with status "{}". See file: "{}"'.format(chunk.status.status.name, chunk.statusFile)) print('Error: Node is already submitted with status "{}". See file: "{}"'.format(chunk.status.status.name, chunk.statusFile))
# exit(-1) # sys.exit(-1)
if args.iteration != -1: if args.iteration != -1:
chunk = node.chunks[args.iteration] chunk = node.chunks[args.iteration]
chunk.process(args.forceCompute) chunk.process(args.forceCompute)
@ -56,7 +57,7 @@ if args.node:
else: else:
if args.iteration != -1: if args.iteration != -1:
print('Error: "--iteration" only make sense when used with "--node".') print('Error: "--iteration" only make sense when used with "--node".')
exit(-1) sys.exit(-1)
toNodes = None toNodes = None
if args.toNode: if args.toNode:
toNodes = graph.findNodes([args.toNode]) toNodes = graph.findNodes([args.toNode])

View file

@ -86,7 +86,7 @@ elif sys.stdin.isatty():
if not inputCmdLineDoc: if not inputCmdLineDoc:
print('No input documentation.') print('No input documentation.')
print('Usage: YOUR_COMMAND --help | {cmd}'.format(cmd=os.path.splitext(__file__)[0])) print('Usage: YOUR_COMMAND --help | {cmd}'.format(cmd=os.path.splitext(__file__)[0]))
exit(-1) sys.exit(-1)
fileStr = '''import sys fileStr = '''import sys
@ -131,7 +131,7 @@ elif args.parser == 'basic':
args_re = re.compile('()--(?P<argLongName>\w+)()()()()') args_re = re.compile('()--(?P<argLongName>\w+)()()()()')
else: else:
print('Error: Unknown input parser "{}"'.format(args.parser)) print('Error: Unknown input parser "{}"'.format(args.parser))
exit(-1) sys.exit(-1)
choiceValues1_re = re.compile('\* (?P<value>\w+):') choiceValues1_re = re.compile('\* (?P<value>\w+):')
choiceValues2_re = re.compile('\((?P<value>.+?)\)') choiceValues2_re = re.compile('\((?P<value>.+?)\)')
@ -299,7 +299,7 @@ outputFilepath = os.path.join(args.output, args.node + '.py')
if not args.force and os.path.exists(outputFilepath): if not args.force and os.path.exists(outputFilepath):
print('Plugin "{}" already exists "{}".'.format(args.node, outputFilepath)) print('Plugin "{}" already exists "{}".'.format(args.node, outputFilepath))
exit(-1) sys.exit(-1)
with open(outputFilepath, 'w') as pluginFile: with open(outputFilepath, 'w') as pluginFile:
pluginFile.write(fileStr) pluginFile.write(fileStr)

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import argparse import argparse
import os import os
import sys
import meshroom import meshroom
meshroom.setupEnvironment() meshroom.setupEnvironment()
@ -63,7 +64,7 @@ def getOnlyNodeOfType(g, nodeType):
if not args.input and not args.inputImages: if not args.input and not args.inputImages:
print('Nothing to compute. You need to set --input or --inputImages.') print('Nothing to compute. You need to set --input or --inputImages.')
exit(1) sys.exit(1)
views, intrinsics = [], [] views, intrinsics = [], []
# Build image files list from inputImages arguments # Build image files list from inputImages arguments
@ -109,7 +110,7 @@ if args.scale > 0:
if args.save: if args.save:
graph.save(args.save) graph.save(args.save)
print('File successfully saved:', args.save) print('File successfully saved:', args.save)
exit(0) sys.exit(0)
# setup cache directory # setup cache directory
graph.cacheDir = args.cache if args.cache else meshroom.core.defaultCacheFolder graph.cacheDir = args.cache if args.cache else meshroom.core.defaultCacheFolder

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import argparse import argparse
import os import os
import sys
from pprint import pprint from pprint import pprint
from collections import Iterable, defaultdict from collections import Iterable, defaultdict
@ -44,7 +45,7 @@ args = parser.parse_args()
if not os.path.exists(args.graphFile): if not os.path.exists(args.graphFile):
print('ERROR: No graph file "{}".'.format(args.graphFile)) print('ERROR: No graph file "{}".'.format(args.graphFile))
exit(-1) sys.exit(-1)
graph = pg.loadGraph(args.graphFile) graph = pg.loadGraph(args.graphFile)

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
import argparse import argparse
import os import os
import sys
from pprint import pprint from pprint import pprint
import meshroom import meshroom
@ -22,7 +23,7 @@ args = parser.parse_args()
if not os.path.exists(args.graphFile): if not os.path.exists(args.graphFile):
print('ERROR: No graph file "{}".'.format(args.node, args.graphFile)) print('ERROR: No graph file "{}".'.format(args.node, args.graphFile))
exit(-1) sys.exit(-1)
graph = meshroom.core.graph.loadGraph(args.graphFile) graph = meshroom.core.graph.loadGraph(args.graphFile)
@ -32,7 +33,7 @@ if args.node:
node = graph.node(args.node) node = graph.node(args.node)
if node is None: if node is None:
print('ERROR: node "{}" does not exist in file "{}".'.format(args.node, args.graphFile)) print('ERROR: node "{}" does not exist in file "{}".'.format(args.node, args.graphFile))
exit(-1) sys.exit(-1)
for chunk in node.chunks: for chunk in node.chunks:
print('{}: {}'.format(chunk.name, chunk.status.status.name)) print('{}: {}'.format(chunk.name, chunk.status.status.name))
if args.verbose: if args.verbose:

View file

@ -113,6 +113,11 @@ meshroomPhotog = PlatformExecutable(
"bin/meshroom_photogrammetry" "bin/meshroom_photogrammetry"
) )
meshroomCompute = PlatformExecutable(
"bin/meshroom_compute"
)
setup( setup(
name="Meshroom", name="Meshroom",
description="Meshroom", description="Meshroom",
@ -127,5 +132,5 @@ setup(
], ],
version=meshroom.__version__, version=meshroom.__version__,
options={"build_exe": build_exe_options}, options={"build_exe": build_exe_options},
executables=[meshroomExe, meshroomPhotog], executables=[meshroomExe, meshroomPhotog, meshroomCompute],
) )