independent process spawn for linux

This commit is contained in:
Mario Voigt 2021-05-08 22:22:29 +02:00
parent 4ecb9b2df9
commit f4a2260687
3 changed files with 135 additions and 127 deletions

View File

@ -6,6 +6,7 @@ import shutil
import os
import sys
import warnings
import shlex
"""
Extension for InkScape 1.X
@ -36,15 +37,14 @@ DETACHED_PROCESS = 0x00000008
class AnimateOrder (inkex.EffectExtension):
def spawnIndependentProcess(self, args): #function to spawn non-blocking inkscape instance. the inkscape command is available because it is added to ENVIRONMENT when Inkscape main instance is started
if os.name == 'nt':
warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback"
if os.name == 'nt':
subprocess.Popen(args, close_fds=True, creationflags=DETACHED_PROCESS)
warnings.simplefilter("default", ResourceWarning)
else:
pid = os.fork()
if pid == 0: # new process
os.system("nohup " + args + " &")
exit()
cmd = "nohup " + " ".join(args) + " &"
cmds = shlex.split(cmd)
subprocess.Popen(cmds, start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
warnings.simplefilter("default", ResourceWarning)
def add_arguments(self, pars):
pars.add_argument("--tab")

View File

@ -8,6 +8,7 @@ import os
import sys
import subprocess
from subprocess import Popen, PIPE
import shlex
import warnings
import inkex
import inkex.command
@ -22,7 +23,6 @@ logger = logging.getLogger(__name__)
DETACHED_PROCESS = 0x00000008
GROUP_ID = 'export_selection_transform'
class ExportObject(inkex.EffectExtension):
def add_arguments(self, pars):
@ -43,15 +43,14 @@ class ExportObject(inkex.EffectExtension):
Popen(["xdg-open", dir], close_fds=True, start_new_session=True).wait()
def spawnIndependentInkscape(self, file): #function to spawn non-blocking inkscape instance. the inkscape command is available because it is added to ENVIRONMENT when Inkscape main instance is started
if os.name == 'nt':
warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback"
if os.name == 'nt':
Popen(["inkscape", file], close_fds=True, creationflags=DETACHED_PROCESS)
warnings.simplefilter("default", ResourceWarning)
else:
pid = os.fork()
if pid == 0: # new process
os.system("nohup inkscape " + file + " &")
exit()
cmd = "nohup inkscape " + file + " &"
cmds = shlex.split(cmd)
subprocess.Popen(cmds, start_new_session=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
warnings.simplefilter("default", ResourceWarning)
def effect(self):
if not self.svg.selected:

View File

@ -36,6 +36,15 @@ Module licenses
possible import file types -> https://www.graphics.rwth-aachen.de/media/openmesh_static/Documentations/OpenMesh-8.0-Documentation/a04096.html
todo:
- debug coplanar color for edges for some cases
- remove empty groups (text)
- abort if 0 faces
- give hints for joinery preparations (apply transform, ungroup, ...)
- update documentation accordingly
- make angleRange global for complete unfolding (to match glue pairs between multiple unfoldings)
- add angleRange to stats
"""
# Compute the third point of a triangle when two points and all edge lengths are given