From: <ror...@us...> - 2007-07-27 12:08:45
|
Revision: 130 http://roreditor.svn.sourceforge.net/roreditor/?rev=130&view=rev Author: rorthomas Date: 2007-07-27 05:08:44 -0700 (Fri, 27 Jul 2007) Log Message: ----------- * moved depchecker console handling * replaced all "print"'s with log().info()or log().error() Modified Paths: -------------- trunk/depchecker.py trunk/lib/ror/depchecker.py trunk/lib/ror/depcheckerplugins/deptools.py trunk/lib/ror/depcheckerplugins/ror_cfg.py trunk/lib/ror/depcheckerplugins/ror_material.py trunk/lib/ror/depcheckerplugins/ror_mesh.py trunk/lib/ror/depcheckerplugins/ror_terrn.py trunk/lib/ror/depcheckerplugins/ror_truck.py trunk/lib/ror/ogrelogger.py trunk/lib/ror/starter.py trunk/lib/ror/svn.py trunk/lib/ror/truckparser.py Modified: trunk/depchecker.py =================================================================== --- trunk/depchecker.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/depchecker.py 2007-07-27 12:08:44 UTC (rev 130) @@ -1,6 +1,18 @@ #Thomas Fischer 31/05/2007, th...@th... import sys, os, os.path +def usage(): + print "usage: %s <path to inspect> <all or unused or missing>" % os.path.basename(sys.argv[0]) + print "for example: %s c:\\ror\\data missing" % os.path.basename(sys.argv[0]) + print " valid modes:" + print " 'all' displays all dependencies, inclusive fulfilled ones" + print " 'missing' displays only unfulfilled dependencies" + print " 'unused' displays resources that are not in use" + print " 'dtree <resourcename>' displays the dependency tree of the given resource name" + print " 'md5sum' creates the md5sums of all files" + sys.exit(0) + + def main(): """ main method @@ -20,9 +32,25 @@ except ImportError: pass + if len(sys.argv) < 3: + usage() + path = sys.argv[1] + if path.strip() == "rordir": + path = ror.settingsManager.getSettingsManager().getSetting("RigsOfRods", "BasePath") + if not os.path.isdir(path): + print "%s is not a valid directory!" % path + usage() + if (len(sys.argv) == 3 and sys.argv[2] in ['all', 'missing', 'unused', 'record']) or (len(sys.argv) == 4 and sys.argv[2] in ['dtree']): + pass + else: + print "%s is not a valid mode, or incorrect arguments!" % sys.argv[2] + usage() + import ror.depchecker - ror.depchecker.main() - + dependfilename = "" + if len(sys.argv) == 4 and sys.argv[2] in ['dtree'] and sys.argv[3].strip() != "": + dependfilename = sys.argv[3].strip() + ror.depchecker.RoRDepChecker(path , sys.argv[2], dependfilename) if __name__=="__main__": main() \ No newline at end of file Modified: trunk/lib/ror/depchecker.py =================================================================== --- trunk/lib/ror/depchecker.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/depchecker.py 2007-07-27 12:08:44 UTC (rev 130) @@ -412,37 +412,3 @@ else: log().info("### all files used") -def usage(): - print "usage: %s <path to inspect> <all or unused or missing>" % os.path.basename(sys.argv[0]) - print "for example: %s c:\\ror\\data missing" % os.path.basename(sys.argv[0]) - print " valid modes:" - print " 'all' displays all dependencies, inclusive fulfilled ones" - print " 'missing' displays only unfulfilled dependencies" - print " 'unused' displays resources that are not in use" - print " 'dtree <resourcename>' displays the dependency tree of the given resource name" - print " 'md5sum' creates the md5sums of all files" - sys.exit(0) - -def main(): - import settingsManager - if len(sys.argv) < 3: - usage() - path = sys.argv[1] - if path.strip() == "rordir": - path = settingsManager.getSettingsManager().getSetting("RigsOfRods", "BasePath") - if not os.path.isdir(path): - print "%s is not a valid directory!" % path - usage() - if (len(sys.argv) == 3 and sys.argv[2] in ['all', 'missing', 'unused', 'record']) or (len(sys.argv) == 4 and sys.argv[2] in ['dtree']): - pass - else: - print "%s is not a valid mode, or incorrect arguments!" % sys.argv[2] - usage() - - dependfilename = "" - if len(sys.argv) == 4 and sys.argv[2] in ['dtree'] and sys.argv[3].strip() != "": - dependfilename = sys.argv[3].strip() - RoRDepChecker(path , sys.argv[2], dependfilename) - -if __name__ == "__main__": - main() Modified: trunk/lib/ror/depcheckerplugins/deptools.py =================================================================== --- trunk/lib/ror/depcheckerplugins/deptools.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/depcheckerplugins/deptools.py 2007-07-27 12:08:44 UTC (rev 130) @@ -1,6 +1,11 @@ #Thomas Fischer 06/07/2007, th...@th... import sys, os, os.path +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")) + +from ror.logger import log +from ror.settingsManager import getSettingsManager + REQUIRES = 'requires' OPTIONAL = 'optional' PROVIDES = 'provides' Modified: trunk/lib/ror/depcheckerplugins/ror_cfg.py =================================================================== --- trunk/lib/ror/depcheckerplugins/ror_cfg.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/depcheckerplugins/ror_cfg.py 2007-07-27 12:08:44 UTC (rev 130) @@ -36,10 +36,10 @@ if not tmp is None: dep.append(tmp) else: - print "ERROR !!! required value not found in terrain config file %s!" % filename + log().error("ERROR !!! required value not found in terrain config file %s!" % filename) if len(dep) == 0: - print "no configuration found in terrain config file " + filename + log().info("no configuration found in terrain config file " + filename) else: return { OPTIONAL:{ Modified: trunk/lib/ror/depcheckerplugins/ror_material.py =================================================================== --- trunk/lib/ror/depcheckerplugins/ror_material.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/depcheckerplugins/ror_material.py 2007-07-27 12:08:44 UTC (rev 130) @@ -29,7 +29,7 @@ #print "no texture found in material file " + filename pass if len(prov) == 0: - print "no material found in material file " + filename + log().info("no material found in material file " + filename) else: return { OPTIONAL:{ Modified: trunk/lib/ror/depcheckerplugins/ror_mesh.py =================================================================== --- trunk/lib/ror/depcheckerplugins/ror_mesh.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/depcheckerplugins/ror_mesh.py 2007-07-27 12:08:44 UTC (rev 130) @@ -16,14 +16,13 @@ def convertToXML(filename): # try to convert to .msh.xml first! cmd = CONVERTERBIN + " \"" + filename+"\"" - print "calling " + cmd + log().info("calling " + cmd) p = subprocess.Popen(cmd, shell = False, cwd = os.path.dirname(CONVERTERBIN), stderr = subprocess.PIPE, stdout = subprocess.PIPE) smart_wait_for_subprocess(p, 10) if not os.path.isfile(os.path.join(os.path.dirname(filename), os.path.basename(filename)+".xml")): - print "conversion of mesh file %s failed!" % filename - - print "mesh converted: " + filename + log().error("conversion of mesh file %s failed!" % filename) + log().info("mesh converted: " + filename) def smart_wait_for_subprocess(sp,timeout=30): """ @@ -89,12 +88,12 @@ convertToXML(filename) try: content = readFile(xmlfilename) - except Exception, e: - print e + except Exception, err: + log().error(str(err)) return dep = parseRE(content) if len(dep) == 0: - print "no material found for file " + filename + log().info("no material found for file " + filename) else: return { OPTIONAL:{ Modified: trunk/lib/ror/depcheckerplugins/ror_terrn.py =================================================================== --- trunk/lib/ror/depcheckerplugins/ror_terrn.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/depcheckerplugins/ror_terrn.py 2007-07-27 12:08:44 UTC (rev 130) @@ -62,7 +62,7 @@ terrnname, ext = os.path.splitext(os.path.basename(filename)) if len(dep) == 0: - print "no objects found in terrain file " + filename + log().error("no objects found in terrain file " + filename) else: return { OPTIONAL:{ Modified: trunk/lib/ror/depcheckerplugins/ror_truck.py =================================================================== --- trunk/lib/ror/depcheckerplugins/ror_truck.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/depcheckerplugins/ror_truck.py 2007-07-27 12:08:44 UTC (rev 130) @@ -6,7 +6,7 @@ p = rorparser() p.parse(filename, verbose=False) if not 'globals' in p.tree.keys(): - print "truck parsing error on file " + filename + log().error("truck parsing error on file " + filename) truckfilename = os.path.basename(filename) truckname, ext = os.path.splitext(truckfilename) matname = p.tree['globals'][0]['data'][2] Modified: trunk/lib/ror/ogrelogger.py =================================================================== --- trunk/lib/ror/ogrelogger.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/ogrelogger.py 2007-07-27 12:08:44 UTC (rev 130) @@ -8,8 +8,9 @@ def messageLogged(self, message, level, debug, logName): # This should be called by Ogre instead of logging - print 'Python Logger Called -- Listener works !!!' - print ">>>", message + #print 'Python Logger Called -- Listener works !!!' + #print ">>>", message + pass def initOgreLogging(): # Create the global log manager instance Modified: trunk/lib/ror/starter.py =================================================================== --- trunk/lib/ror/starter.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/starter.py 2007-07-27 12:08:44 UTC (rev 130) @@ -25,7 +25,7 @@ jpg1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap() wx.StaticBitmap(self, wx.ID_ANY, jpg1, (0, 0), (jpg1.GetWidth(), jpg1.GetHeight())) except IOError: - print "Image file %s not found" % imageFile + log().error("Image file %s not found" % imageFile) raise SystemExit @@ -128,7 +128,7 @@ import ror.depchecker ror.depchecker.RoRDepChecker(self.rordir, "all", "") file = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..\\..\\graphs\\alldependencies.png")) - print file + #print file if os.path.isfile(file): dlg = wx.MessageDialog(self, "Graph successfully created:\n"+file, "Info", wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() Modified: trunk/lib/ror/svn.py =================================================================== --- trunk/lib/ror/svn.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/svn.py 2007-07-27 12:08:44 UTC (rev 130) @@ -23,7 +23,7 @@ global changes changes += 1 #print event_dict - print str(event_dict['action']) + ", " + event_dict['path'] + log().info(str(event_dict['action']) + ", " + event_dict['path']) def getRevision(client=None, path=None): if client is None: @@ -46,7 +46,7 @@ strict_node_history=True, limit=0) for e in log: - print "--- r%d, author: %s:\n%s\n" %(e['revision'].number, e['author'], e['message']) + log().info("--- r%d, author: %s:\n%s\n" %(e['revision'].number, e['author'], e['message'])) if len(log) > 0: return True except: @@ -65,11 +65,11 @@ limit=0) def showLog(client, startrev, endrev): - print "------------------------------------" - print "Changelog from revision %d to revision %d\n" % (startrev, endrev) + log().info("------------------------------------") + log().info("Changelog from revision %d to revision %d\n" % (startrev, endrev)) log = getLog(client, startrev, endrev) for e in log: - print "--- r%d, author: %s:\n%s\n" %(e['revision'].number, e['author'], e['message']) + log().info("--- r%d, author: %s:\n%s\n" %(e['revision'].number, e['author'], e['message'])) def svnupdate(callback = None): global changes @@ -86,7 +86,7 @@ pass revision_before = getRevision(client, path) - print "updating from revision %d ..." % revision_before + log().info("updating from revision %d ..." % revision_before) if callback is None: client.callback_notify = notify else: @@ -97,21 +97,21 @@ revision = pysvn.Revision(pysvn.opt_revision_kind.head), ignore_externals = False) revision_after = getRevision(client, path) - print "updated to revision %d." % revision_after + log().info("updated to revision %d." % revision_after) if revision_before == revision_after and changes == 2: - print "already up to date!" + log().info("already up to date!") elif changes > 2: if revision_before != revision_after: - print "updated! please restart the application!" + log().info("updated! please restart the application!") showLog(client, revision_before + 1, revision_after) else: - print "no files updated, but restored! please restart the application!" + log().info("no files updated, but restored! please restart the application!") except Exception, inst: - print "error while updating: " + str(inst) - print "done." + log().error( "error while updating: " + str(inst)) + log().error("done.") def svncheckout(): - print "checkout" + log().info("checkout") path = getRootPath() changes = 0 try: @@ -119,7 +119,7 @@ client.callback_notify = notify client.checkout(URL, path) except: - print "error while checkout!" + log().error("error while checkout!") def createBackup(): import shutil Modified: trunk/lib/ror/truckparser.py =================================================================== --- trunk/lib/ror/truckparser.py 2007-07-27 11:38:05 UTC (rev 129) +++ trunk/lib/ror/truckparser.py 2007-07-27 12:08:44 UTC (rev 130) @@ -1,10 +1,13 @@ #!/bin/env python # Thomas Fischer 16/05/2007 thomas (at) thomasfischer.biz import sys, os, os.path, tempfile, pickle - ## default values: required:True - ## please note: unkown args are marked with 'WHAT IS THIS' +from ror.logger import log +from ror.settingsManager import getSettingsManager + + # default values: required:True + # please note: unkown args are marked with 'WHAT IS THIS' class rorparser: - ### This specifies all valid commands + # This specifies all valid commands commands = { # set_beam_defaults changes the beams (but also the hydros and ropes) default characteristics that will be used for the beams declared after the line. You can use this line many times to make different groups of beams that have different characteristics (e.g. stronger chassis, softer cab, etc.). This method is better than the globeams command that is now deprecated. The parameters comes on the same line, after set_beam_defaults. You can use the first parameters (most usefull) and safely ignore the last parameters. 'set_beam_defaults':[ @@ -605,7 +608,7 @@ line = content[lineno] # strip line-endings line = line.strip() - #print lineno, line + #log.info(lineno+","+ line) if line.strip() == "": # add blank lines to comments self.addComment(actualsection, line, lineno, False) @@ -741,14 +744,15 @@ def save(self): #(fid, filename) = tempfile.mkstemp(suffix='.RoRObject') filename = self.filename + "_pickle" - print "trying to save Settings to file %s for file %s" % (filename, os.path.basename(self.filename)) + log().info("trying to save Settings to file %s for file %s" % (filename, os.path.basename(self.filename))) try: fh = open(filename, 'w') pickle.dump(self.tree, fh) fh.close() - print "saving successfull!" - except: - print "error while saving settings" + log().info("saving successfull!") + except Exception, err: + log().error("error while saving settings") + log().error(str(err)) def isFloat(self, s): @@ -759,32 +763,34 @@ return i def printtree(self): + rstr = "" for s in self.tree.keys(): if len(self.tree[s]) == 0: continue - print "" - print "===========================================================================================================================================================================" - print "%s: %d" % (s, len(self.tree[s])) + rstr += "\n" + rstr += "===========================================================================================================================================================================\n" + rstr += "%s: %d\n" % (s, len(self.tree[s])) # for non original columns (generated ones) if not self.sections.has_key(s): - print self.tree[s] + rstr += self.tree[s] continue for column in self.sections[s]: - sys.stdout.write("| %-15s" % (column['name'][0:15])) - sys.stdout.write("\n") - print "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + rstr += "| %-15s" % (column['name'][0:15]) + rstr += "\n" + rstr += "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n" for line in self.tree[s]: for arg in line['data']: try: if arg.isdigit() or self.isFloat(arg): - sys.stdout.write("|%15.3f " % (round(float(arg),4))) + rstr += "|%15.3f " % (round(float(arg),4)) else: - sys.stdout.write("|%15s " % (str(arg)[0:15])) + rstr += "|%15s " % (str(arg)[0:15]) except: - sys.stdout.write("|%15s " % (str(arg)[0:15])) + rstr += "|%15s " % (str(arg)[0:15]) if 'errors' in line.keys(): - sys.stdout.write("[ERRORS: %d] "%(len(line['errors']))) - sys.stdout.write("(origin: %d)\n"%(line['originline'])) + rstr += "[ERRORS: %d] "%(len(line['errors'])) + rstr += "(origin: %d)\n"%(line['originline']) + log().info(rstr) def getLine(self, lineno): for skey in self.tree.keys(): @@ -820,8 +826,8 @@ result.append(data) n = self.getnextLine(n['originline']) - for r in result: - print r + #for r in result: + # print r def getnextLine(self, lineno): value = {'originline':9999999999} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |