Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
objects = cc.compile([fname], output_dir=tmpdir)
cc.link_executable(objects, os.path.join(tmpdir, "a.out"))
return True
except Exception:
return False
finally:
if oldstderr is not None:
os.dup2(oldstderr, sys.stderr.fileno())
if devnull is not None:
devnull.close()
shutil.rmtree(tmpdir)
# py2exe needs to be installed to work
try:
import py2exe
py2exe.Distribution # silence unused import warning
py2exeloaded = True
# import py2exe's patched Distribution class
from distutils.core import Distribution
except ImportError:
py2exeloaded = False
def runcmd(cmd, env):
if (sys.platform == 'plan9'
and (sys.version_info[0] == 2 and sys.version_info[1] < 7)):
# subprocess kludge to work around issues in half-baked Python
# ports, notably bichued/python:
_, out, err = os.popen3(cmd)
return str(out), str(err)
else:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env)
"""
import sys, os
import tempfile
import atexit
import itertools
import shutil
import ConfigParser
from py2exe.build_exe import py2exe as build_exe
import py2exe
from find_modules import find_modules
from ntsvc.helpers import helpers
class TwistedAppDistribution(py2exe.Distribution):
"""Parse the 'appconfig' option, setting the 'service' and 'data_files'
attrs based on the filename.
If ntsvc.cfg already exists, use those values to configure myself instead
of 'appconfig'.
"""
def __init__(self, attrs):
if os.path.isfile('ntsvc.cfg'):
attrs.pop('appconfig', 'DONTCARE') # eliminates a distutils warning
cp = ConfigParser.ConfigParser()
cp.read('ntsvc.cfg')
self.twisted = dict(cp.items('service'))
config = self.twisted['basecf']
short_name = self.twisted['svcname']
else:
config = attrs.pop('appconfig', '//missing option appconfig//')
short_name = os.path.splitext(os.path.basename(config))[0]