本文整理汇总了Python中pyaid.debug.Logger.Logger.writeError方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.writeError方法的具体用法?Python Logger.writeError怎么用?Python Logger.writeError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.debug.Logger.Logger
的用法示例。
在下文中一共展示了Logger.writeError方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runPythonExec
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
def runPythonExec(script, kwargs =None):
from nimble.NimbleEnvironment import NimbleEnvironment
from nimble.data.NimbleResponseData import NimbleResponseData
from nimble.data.enum.DataKindEnum import DataKindEnum
try:
nimble.cmds.undoInfo(openChunk=True)
except Exception as err:
return False
try:
# Create a new, temporary module in which to run the script
module = imp.new_module('runExecTempModule')
# Initialize the script with script inputs
setattr(module, NimbleEnvironment.REMOTE_KWARGS_KEY, kwargs if kwargs is not None else dict())
setattr(module, NimbleEnvironment.REMOTE_RESULT_KEY, dict())
# Executes the script in the new module
exec_(script, module.__dict__)
# Find a NimbleScriptBase derived class definition and if it exists, run it to populate the
# results
for name,value in Reflection.getReflectionDict(module).iteritems():
if not inspect.isclass(value):
continue
if NimbleScriptBase in value.__bases__:
getattr(module, name)().run()
break
# Retrieve the results object that contains all results set by the execution of the script
result = getattr(module, NimbleEnvironment.REMOTE_RESULT_KEY)
except Exception as err:
logger = Logger('runPythonExec', printOut=True)
logger.writeError('ERROR: Failed Remote Script Execution', err)
result = NimbleResponseData(
kind=DataKindEnum.PYTHON_SCRIPT,
response=NimbleResponseData.FAILED_RESPONSE,
error=str(err) )
# If a result dictionary contains an error key format the response as a failure
try:
errorMessage = ArgsUtils.extract(
NimbleEnvironment.REMOTE_RESULT_ERROR_KEY, None, result)
if errorMessage:
return NimbleResponseData(
kind=DataKindEnum.PYTHON_SCRIPT,
response=NimbleResponseData.FAILED_RESPONSE,
error=errorMessage,
payload=result)
except Exception as err:
pass
try:
nimble.cmds.undoInfo(closeChunk=True)
except Exception as err:
return False
return result
示例2: SocketHandler
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
class SocketHandler(SocketServer.StreamRequestHandler):
"""A class for..."""
#===================================================================================================
# C L A S S
SERVICE_UID = 'test'
VERBOSE = False
WORK_PATH = '/var/lib/'
RUN_PATH = '/var/run/'
LOG_PATH = '/var/log/'
#___________________________________________________________________________________________________ __init__
def __init__(self, request, client_address, server):
self._log = Logger(self)
self._log.write('Socket handler created')
SocketServer.StreamRequestHandler.__init__(self, request, client_address, server)
#===================================================================================================
# G E T / S E T
#___________________________________________________________________________________________________ GS: returnResponse
@property
def returnResponse(self):
return getattr(self.__class__, 'RETURN_RESPONSE', False)
#===================================================================================================
# P U B L I C
#___________________________________________________________________________________________________ handle
def handle(self):
try:
data = self.rfile.readline().strip()
self._log.write('HANDLE: ' + str(data))
try:
result = self._respondImpl(JSON.fromString(unquote(data)))
except Exception as err:
self._log.writeError('RESPOND FAILURE', err)
if self.returnResponse:
self.wfile.write(JSON.asString({'error':1}))
return
if self.returnResponse:
out = {'error':0}
if result:
out['payload'] = result
self.wfile.write(out)
except Exception as err:
self._log.write('HANDLE FAILURE', err)
return
#===================================================================================================
# P R O T E C T E D
#___________________________________________________________________________________________________ _respondImpl
def _respondImpl(self, data):
pass
示例3: DataFormatConverter
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
class DataFormatConverter(object):
"""A class for converting between various data interchange formats, e.g. XML and JSON."""
#===================================================================================================
# C L A S S
#___________________________________________________________________________________________________ __init__
def __init__(self):
"""Creates a new instance of ClassTemplate."""
self._type = None
self._src = None
self._log = Logger('DataFormatConverter')
self._path = None
#===================================================================================================
# G E T / S E T
#___________________________________________________________________________________________________ GS: propertyName
@property
def source(self):
return self._src
#===================================================================================================
# P U B L I C
#___________________________________________________________________________________________________ load
def load(self, path, fileType):
if not os.path.exists(path):
self._log.write('ERROR: Path does not exist [%s]. Unable to load.' % path)
return False
try:
fh = codecs.open(path, 'r', 'utf-8')
res = fh.read()
fh.close()
enc = res.encode('utf-8')
self.loads(enc, fileType)
except Exception, err:
self._log.writeError('Failed to load source file [%s].' % path, err)
return False
self._path = path
return True
示例4: IncludeCompressor
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
class IncludeCompressor(object):
#===================================================================================================
# C L A S S
_REMOVE_COMMENT_RE = re.compile('/\*.+\*/', re.DOTALL)
_REMOVE_COMMENT_LINE_RE = re.compile('(^|\n)[\s\t]*//.+(\n|$)')
JS_TYPE = 'js'
CSS_TYPE = 'css'
#___________________________________________________________________________________________________ __init__
def __init__(self, compileCoffee =False):
self._log = Logger('IncludeCompressor')
self._compileCoffee = compileCoffee
#===================================================================================================
# P U B L I C
#___________________________________________________________________________________________________ compress
def compress(self, rootPath):
if not self._fileExists(rootPath):
return False
elif os.path.isfile(rootPath):
return self.compressFile(rootPath)
else:
return self.compressPath(rootPath)
#___________________________________________________________________________________________________ compressFile
def compressFile(self, rootPath, directory =None):
if not self._fileExists(rootPath):
return False
if self._compileCoffee:
try:
from pyaid.web.coffeescript.CoffeescriptBuilder import CoffeescriptBuilder
CoffeescriptBuilder.compileAllOnPath(rootPath, os.path.dirname(rootPath), True)
self._log.write('Coffeescript compiled.')
except Exception, err:
self._log.writeError('Failed to compile coffeescript file.', err)
return False
return self._compressFile(rootPath, directory)
示例5: MarkupTag
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
#.........这里部分代码省略.........
#___________________________________________________________________________________________________ GS: backCapPolicy
@property
def backCapPolicy(self):
return self.getAttrFromClass('BACK_CAP_POLICY')
#___________________________________________________________________________________________________ GS: parent
@property
def parent(self):
return self._parent
@parent.setter
def parent(self, value):
self._parent = value
#___________________________________________________________________________________________________ GS: renderTemplate
@property
def renderTemplate(self):
if self._renderTemplate is None:
self._renderTemplate = self.getClassAttr('TEMPLATE', '')
return self._renderTemplate
@renderTemplate.setter
def renderTemplate(self, value):
self._renderTemplate = value
#___________________________________________________________________________________________________ GS: log
@property
def log(self):
return self._log
#___________________________________________________________________________________________________ GS: replacementName
@property
def replacementName(self):
return self._replacementName
#===================================================================================================
# P U B L I C
#___________________________________________________________________________________________________ getAttributeList
@classmethod
def getAttributeList(cls):
t = TagAttributesEnum
out = t.THEME + t.ID + t.HTML_CLASS + t.HTML_STYLE + t.HTML_DATA + t.ACCENTED + t.CLEAR + \
t.GROUP + t.HTML_ATTR
if cls.getAttrFromClass('PRIMARY_ATTR', None):
out += t.VALUE
return out
#___________________________________________________________________________________________________ clone
def clone(self, tree=True, replacements=None, **kwargs):
if replacements and self.replacementName:
if not isinstance(replacements, list):
replacements = [replacements]
for r in replacements:
if r.replacementName == self.replacementName:
return r
return self._cloneImpl(**kwargs)
#___________________________________________________________________________________________________ getNonPassthruRootTag
def getNonPassthruRootTag(self):
if self.isPassthruTag:
return None
return self
#___________________________________________________________________________________________________ confirmClosed
def confirmClosed(self):
return True
#___________________________________________________________________________________________________ useBackground
def useBackground(self):
self.attrs.classes.add('v-S-bck', self.attrs.styleGroup)
#___________________________________________________________________________________________________ addError
def addError(self, value):
self._errors.append(value)
#___________________________________________________________________________________________________ makeRenderAttributes
def makeRenderAttributes(self):
# Don't allow the tags _renderImpl to be called multiple times
if self._attrsReady:
return self._attrData
try:
self._attrData = self._renderImpl()
except Exception, err:
MarkupTagError(
tag=self,
errorDef=MarkupTagError.RENDER_FAILURE
).log()
self._log.writeError([
'Tag Render failure',
'TAG' + str(self)
], err)
return None
self._attrsReady = True
return self._attrData
示例6: TrackCsvImporter
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
class TrackCsvImporter(object):
""" Imports track data from CSV formatted spreadsheets into the local Cadence database. """
#===============================================================================
# C L A S S
# Used to break trackway specifier into separate type and number entries
_TRACKWAY_PATTERN = re.compile('(?P<type>[^0-9\s\t]+)[\s\t]*(?P<number>[^\(\s\t]+)')
_UNDERPRINT_IGNORE_TRACKWAY_STR = ':UTW'
_OVERPRINT_IGNORE_TRACKWAY_STR = ':OTW'
#_______________________________________________________________________________
def __init__(self, path =None, logger =None):
"""Creates a new instance of TrackCsvImporter."""
self._path = path
self.created = []
self.modified = []
self.fingerprints = dict()
self.remainingTracks = dict()
self._logger = logger
if not logger:
self._logger = Logger(self, printOut=True)
#===============================================================================
# P U B L I C
#_______________________________________________________________________________
def read(self, session, analysisSession, path =None, compressed =False):
""" Reads from the spreadsheet located at the absolute path argument and adds each row
to the tracks in the database. """
if path is not None:
self._path = path
if self._path is None:
return False
model = Tracks_Track.MASTER
for existingTrack in session.query(model).all():
self.remainingTracks[existingTrack.uid] = existingTrack.fingerprint
try:
data = pd.read_csv(self._path)
except Exception as err:
self._writeError({
'message':'ERROR: Unable to read CSV file "%s"' % self._path,
'error':err })
return
if data is None:
self._writeError({
'message':'ERROR: Failed to create CSV reader for file "%s"' % self._path })
return
for index, row in data.iterrows():
# Skip any rows that don't start with the proper numeric index value, which
# includes the header row (if it exists) with the column names
try:
index = int(row[0])
except Exception:
continue
rowDict = dict()
for column in Reflection.getReflectionList(TrackCsvColumnEnum):
value = row[column.index]
if value and StringUtils.isStringType(value) and not StringUtils.isTextType(value):
# Try to decode the value into a unicode string using common codecs
for codec in ['utf8', 'MacRoman', 'utf16']:
try:
decodedValue = value.decode(codec)
if decodedValue:
value = decodedValue
break
except Exception:
continue
try:
# Check to see if the value is NaN, and if it is replace it with an empty
# string to be ignored during import
value = '' if np.isnan(value) else value
except Exception:
pass
if value != '' or value is None:
rowDict[column.name] = value
self.fromSpreadsheetEntry(rowDict, session)
for uid, fingerprint in DictUtils.iter(self.remainingTracks):
# Iterate through the list of remaining tracks, which are tracks not found by the
# importer. If the track is marked as custom (meaning it is not managed by the importer)
# it is ignored. Otherwise, the track is deleted from the database as a track that no
# longer exists.
track = Tracks_Track.MASTER.getByUid(uid, session)
if track.custom:
continue
#.........这里部分代码省略.........
示例7: CoffeescriptBuilder
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
#.........这里部分代码省略.........
print("\n")
s = "IMPORTING:"
for imp in libImports:
s += "\n\t" + imp.package
for inc in libIncludes:
s += "\n\tEXTERNAL: " + inc.package
self._log.add(s)
print("\n")
s = "EXCLUDING:"
for imp in sharedImports:
s += "\n\t" + imp.package
for inc in sharedIncludes:
s += "\n\tEXTERNAL: " + inc.package
self._log.add(s)
# ---------------------------------------------------------------------------------------
# Construct intermediate compilation file.
assembledFile = self._assembleFile(target, libImports, sharedImports, {"modules": modules})
if assembledFile is None:
self._log.write("ERROR: File assembly failed.")
return
# ---------------------------------------------------------------------------------------
# Compile to Javascript
if not self.buildOnly:
self._compileToJavascript(target, assembledFile, libIncludes)
if self._verbose:
print("\n" + ("-" * 100) + "\n")
except Exception as err:
print("\n\n\n")
self._log.writeError(
"ERROR: Compilation failure for: %s\n\tsource: %s\n\troot: %s"
% (target.package, target.path, target.rootPath),
err,
)
# ___________________________________________________________________________________________________ _constructTarget
def _constructTarget(self, target):
try:
if self._verbose:
print("\n\n" + ("-" * 100) + "\n")
self._log.write(
"EXECUTABLE: %s\n\tsource: %s\n\troot: %s" % (target.package, target.path, target.rootPath)
)
# ---------------------------------------------------------------------------------------
# Handle imports and requires
self._parseIncludes(target)
self._processRequires(target)
if self._verbose:
s = "IMPORTING:"
for imp in self._imports[target.package]:
s += "\n\t" + imp.package
self._log.write(s)
# ---------------------------------------------------------------------------------------
# Construct intermediate compilation file.
assembledFile = self._assembleFile(target)
if assembledFile is None:
self._log.write("ERROR: File assembly failed.")
return
示例8: TrackExporter
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
class TrackExporter(object):
"""A class for..."""
#===============================================================================
# C L A S S
DELETED_IDENTIFIER = u'##DEL##'
#_______________________________________________________________________________
def __init__(self, logger =None):
"""Creates a new instance of TrackExporter."""
self.results = None
self.logger = logger
self.modifications = 0
if not logger:
self.logger = Logger(self, printOut=True)
#===============================================================================
# P U B L I C
#_______________________________________________________________________________
def process(self, session, difference =True):
"""Doc..."""
if self.results is not None:
return True
results = []
model = Tracks_Track.MASTER
if session is None:
session = model.createSession()
trackStores = session.query(model).all()
index = 0
indices = NumericUtils.linearSpace(0, len(trackStores), roundToIntegers=True)[1:]
for trackStore in trackStores:
track = trackStore.getMatchingTrack(session)
if track is None:
self.modifications += 1
results.append({'uid':trackStore.uid, 'action':self.DELETED_IDENTIFIER})
self.logger.write(
u'<div>DELETED: %s</div>' % DictUtils.prettyPrint(
trackStore.toDict(uniqueOnly=True)))
else:
if difference:
diff = trackStore.toDiffDict(track.toDict())
if diff is not None:
self.modifications += 1
results.append(diff)
self.logger.write(
u'<div>MODIFIED: %s</div>' % trackStore.fingerprint)
else:
results.append(track.toDict())
index += 1
if index in indices:
self.logger.write(
u'<div style="color:#33CC33">%s%% Complete</div>' % StringUtils.toUnicode(
10*(indices.index(index) + 1)))
self.logger.write(u'<div style="color:#33CC33">100% Complete</div>')
self.results = results
return True
#_______________________________________________________________________________
def write(self, session, path, pretty =False, gzipped =True, difference =True):
if self.results is None and not self.process(session, difference):
return False
try:
JSON.toFile(path, self.results, pretty=pretty, gzipped=gzipped, throwError=True)
return True
except Exception as err:
self.logger.writeError([
u'ERROR: Unable to write export file',
u'PATH: ' + StringUtils.toUnicode(path)], err)
return False
#===============================================================================
# I N T R I N S I C
#_______________________________________________________________________________
def __repr__(self):
return self.__str__()
#_______________________________________________________________________________
def __unicode__(self):
return StringUtils.toUnicode(self.__str__())
#_______________________________________________________________________________
def __str__(self):
return '<%s>' % self.__class__.__name__
示例9: DataFormatConverter
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
class DataFormatConverter(object):
"""A class for converting between various data interchange formats, e.g. XML and JSON."""
#===================================================================================================
# C L A S S
#___________________________________________________________________________________________________ __init__
def __init__(self):
"""Creates a new instance of ClassTemplate."""
self._type = None
self._src = None
self._log = Logger('DataFormatConverter')
self._path = None
#===================================================================================================
# G E T / S E T
#___________________________________________________________________________________________________ GS: propertyName
@property
def source(self):
return self._src
#===================================================================================================
# P U B L I C
#___________________________________________________________________________________________________ load
def load(self, path, fileType):
if not os.path.exists(path):
self._log.write('ERROR: Path does not exist [%s]. Unable to load.' % path)
return False
try:
fh = codecs.open(path, 'r', 'utf-8')
res = fh.read()
fh.close()
enc = res.encode('utf-8')
self.loads(enc, fileType)
except Exception as err:
self._log.writeError('Failed to load source file [%s].' % path, err)
return False
self._path = path
return True
#___________________________________________________________________________________________________ load
def loads(self, srcString, srcType):
if srcString is None:
self._log.write('ERROR: Source string is empty or invalid.')
return False
srcString = StringUtils.toStr2(srcString)
self._path = None
self._src = srcString
self._type = srcType
return True
#___________________________________________________________________________________________________ convertDirectory
def convertDirectory(self, path, srcType, targetType, recursive =False):
if srcType is None or targetType is None:
self._log.write('ERROR: Source and/or target types are invalid. Operation aborted.')
return False
if not os.path.exists(path):
self._log.write('ERROR: The specified path [%s] does not exist. Operation aborted.' \
% str(path))
return False
if recursive:
FileUtils.walkPath(path, self._convertInDirectory, [srcType, targetType])
else:
self._convertInDirectory([srcType, targetType], path, os.listdir(path))
return True
#___________________________________________________________________________________________________ writeToFile
def writeToFile(self, targetType, path =None):
if path is None and self._path is None:
self._log.write('ERROR: Unable to write to file, no path was specified.')
return False
# Assign the reader based on source type
reader = self._getParserFromType()
if reader is None:
self._log.write('ERROR: Unrecognized source type [%s]. Unable to convert.' % self._type)
return False
# Assign writer based on target type
writer = self._getParserFromType(targetType)
if writer is None:
self._log.write('ERROR: Unrecognized conversion target type [%s]. Unable to convert.' \
% targetType)
return False
path = path if path else self._path
d = os.path.dirname(path)
f = os.path.basename(path).split('.')[0]
f += '.' + writer.TYPE_ID
if not os.path.exists(d):
#.........这里部分代码省略.........
示例10: IncludeCompressor
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
class IncludeCompressor(object):
#===================================================================================================
# C L A S S
_REMOVE_COMMENT_RE = re.compile('/\*.+\*/', re.DOTALL)
_REMOVE_COMMENT_LINE_RE = re.compile('(^|\n)[\s\t]*//.+(\n|$)')
JS_TYPE = 'js'
CSS_TYPE = 'css'
#___________________________________________________________________________________________________ __init__
def __init__(self, compileCoffee =False):
self._log = Logger('IncludeCompressor')
self._compileCoffee = compileCoffee
#===================================================================================================
# P U B L I C
#___________________________________________________________________________________________________ compress
def compress(self, rootPath):
if not self._fileExists(rootPath):
return False
elif os.path.isfile(rootPath):
return self.compressFile(rootPath)
else:
return self.compressPath(rootPath)
#___________________________________________________________________________________________________ compressFile
def compressFile(self, rootPath, directory =None):
if not self._fileExists(rootPath):
return False
if self._compileCoffee:
try:
from pyaid.web.coffeescript.CoffeescriptBuilder import CoffeescriptBuilder
CoffeescriptBuilder.compileAllOnPath(rootPath, os.path.dirname(rootPath), True)
self._log.write('Coffeescript compiled.')
except Exception as err:
self._log.writeError('Failed to compile coffeescript file.', err)
return False
return self._compressFile(rootPath, directory)
#___________________________________________________________________________________________________ compressPath
def compressPath(self, rootPath):
# First compile any coffee scripts to js files
if self._compileCoffee:
try:
from pyaid.web.coffeescript.CoffeescriptBuilder import CoffeescriptBuilder
CoffeescriptBuilder.compileAllOnPath(rootPath, rootPath, True)
self._log.write('Coffee scripts compiled.')
except Exception as err:
self._log.writeError('Failed to compile coffeescript files.', err)
return False
FileUtils.walkPath(rootPath, self._compressInFolder, None)
self._log.write('Compression operation complete.')
return True
#===================================================================================================
# P R O T E C T E D
#___________________________________________________________________________________________________ _fileExists
def _fileExists(self, rootPath):
if not os.path.exists(rootPath):
self._log.write('ERROR: [%s] does not exist. Operation aborted.' % rootPath)
return False
return True
#___________________________________________________________________________________________________ _compressFile
def _compressFile(self, target, directory):
# Skip compiled files.
if target.endswith('comp.js') or target.endswith('comp.css'):
return False
if target.endswith('.js'):
fileType = IncludeCompressor.JS_TYPE
elif target.endswith('.css'):
fileType = IncludeCompressor.CSS_TYPE
else:
return False
if not directory:
directory = ''
if not directory.endswith(os.sep) and not target.startswith(os.sep):
directory += os.sep
inFile = directory + target
tempFile = directory + target + '.temp'
try:
fh = open(inFile, 'r')
fileString = fh.read()
fh.close()
except Exception as err:
self._log.writeError('FAILED: Unable to read ' + str(inFile), err)
return False
#.........这里部分代码省略.........
示例11: printResult
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
# Check for PySide site package shared libraries
foundLocation = None
for p in sys.path:
p = FileUtils.createPath(p, u'PySide', isDir=True)
if not os.path.exists(p):
continue
if os.path.exists(FileUtils.createPath(p, u'QtCore.so', isFile=True)):
foundLocation = p
break
printResult(u'PySide (Package Libraries)', u'PASSED' if foundLocation else u'FAILED')
if foundLocation:
print u' * ', foundLocation
# Check for PySide
try:
from PySide import QtCore
printResult(u'PySide', u'PASSED')
except Exception, err:
printResult(u'PySide', u'FAILED')
logger.writeError(u'Unable to import PySide', err)
# Check for PyGlass
try:
from pyglass.app.PyGlassEnvironment import PyGlassEnvironment
printResult(u'PyGlass', u'PASSED')
except Exception, err:
printResult(u'PyGlass', u'FAILED')
logger.writeError(u'Unable to import PyGlass', err)
示例12: CoffeescriptBuilder
# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import writeError [as 别名]
#.........这里部分代码省略.........
# Process requires for all of the targets
for t in (targets + imports + modules):
self._processRequires(t)
#---------------------------------------------------------------------------------------
# IMPORTS
# Compile all excludes skipping any exec or lib files that are listed in the import
# statements.
importExcludes = []
for t in targets:
for imp in self._imports[t.package]:
if not (imp.isExec or imp.isLib or imp.isInList(importExcludes)):
importExcludes.append(imp)
# Compile all imports needed for the library. Any excludes are added to the shared
# library to be made accessible via the VIZME registry.
libImports = []
sharedImports = []
for t in (imports + modules):
for imp in self.imports[t.package]:
if not imp.isInList(libImports):
if imp.isInList(importExcludes):
if not imp.isInList(sharedImports):
sharedImports.append(imp)
else:
libImports.append(imp)
libImports.append(target)
#---------------------------------------------------------------------------------------
# INCLUDES
# Compile all includes to exclude from the library because they already exist in a
# target.
includeExcludes = []
for t in targets:
for inc in self._includes[t.package]:
if not inc.isInList(includeExcludes):
includeExcludes.append(inc)
# Compile all includes needed for the library.
libIncludes = []
sharedIncludes = []
# Add the top-level includes directly because they are not handled implicitly like
# the import case
for inc in includes:
if inc.isInList(includeExcludes):
sharedIncludes.append(inc)
else:
libIncludes.append(inc)
for t in (imports + modules):
for inc in self.includes[t.package]:
if not inc.isInList(libIncludes):
if inc.isInList(includeExcludes):
if not inc.isInList(sharedIncludes):
sharedIncludes.append(inc)
else:
libIncludes.append(inc)
if self._verbose:
print '\n'
s = 'IMPORTING:'
for imp in libImports:
s += '\n\t' + imp.package
for inc in libIncludes:
s += '\n\tEXTERNAL: ' + inc.package
self._log.add(s)
print '\n'
s = 'EXCLUDING:'
for imp in sharedImports:
s += '\n\t' + imp.package
for inc in sharedIncludes:
s += '\n\tEXTERNAL: ' + inc.package
self._log.add(s)
#---------------------------------------------------------------------------------------
# Construct intermediate compilation file.
assembledFile = self._assembleFile(
target, libImports, sharedImports, {'modules':modules}
)
if assembledFile is None:
self._log.write('ERROR: File assembly failed.')
return
#---------------------------------------------------------------------------------------
# Compile to Javascript
if not self.buildOnly:
self._compileToJavascript(target, assembledFile, libIncludes)
if self._verbose:
print "\n" + ('-'*100) + '\n'
except Exception, err:
print "\n\n\n"
self._log.writeError(
'ERROR: Compilation failure for: %s\n\tsource: %s\n\troot: %s'
% (target.package, target.path, target.rootPath), err)