RE: New to Python need on advice on this script
Jim, In Python 2.5 under ArcMap 9.3 domains can be only listed. To get to the domain values, they need to be converted to tables. Also, the default value cannot be obtained from the existing GP API. Very annoying! The workaround is to use VBA ArcObjects or connect to the database directly, if possible, and extract the information from the GDB. This latter will work for PGDB, not sure about FGDB. Regards, Valentina Boycheva From: Jim Valenza [mailto:jim.vale...@gmail.com] Sent: Tuesday, November 10, 2009 2:33 PM To: python-list@python.org Subject: New to Python need on advice on this script Hello all - I'm new to the world of Python as I am a GIS guy who would like to broaden his horizons. I have a question about a script that we've been working on: The purpose of the code is to Syncronize SDE DropBox with Regulatory Project working files. I am looking for where the script dumps the domain list to a table and loops through the table? Is It necessary? Seems like you should be able to simply loop through the domain list. I was just trying to see if there was a more straitforward way. Thanks The script is as follows: # Create the Geoprocessor import sys, string, os, arcgisscripting, shutil, time gp = arcgisscripting.create() # Jim V testing # Allow output to overwrite gp.OverwriteOutput = 1 gp.AddToolbox("C://Program Files//ArcGIS//ArcToolbox//Toolboxes//Data Management Tools.tbx") #---create a logging file named "MMDD HH_MM_QualityControlLog.txt" theTime = time.strftime('%Y%m%d %H_%M') #logfilename = "H:\\Development\\Python\\" + theTime + "_PODsQAQCLog.txt" logfilename = "L:\\SharedData\\Denver\\Regulatory\\GIS\\Powder_River_Basin\\Pipeline\\ QAQC_Scripts\\" + theTime + "_PODsQAQCLog.txt" log = open(logfilename,'w') log.write(time.ctime() + "\n") print time.ctime() THE_WORKSPACE = os.path.normpath("L:/SharedData/Denver/Regulatory/GIS/Powder_River_Basin ") + "\\" #REAL MODE LINE #THE_WORKSPACE = os.path.normpath("H:/Development/testdata") + "\\" #TEST MODE LINE log.write("THE_WORKSPACE IS " + THE_WORKSPACE + "\n") print "THE_WORKSPACE IS " + THE_WORKSPACE P_CODE = "P_CODE" #Create table of valid P_CODEs and convert to List gp.DomainToTable_management(r"L:\SharedData\Denver\Regulatory\GIS\Powder _River_Basin\GIS_Data\RMP_Current_Geodatabase\rmp_2_5.mdb", \ "regulatory_p_code", r"L:\SharedData\Denver\Regulatory\GIS\Powder_River_Basin\Pipeline\QAQC_S cripts\test.mdb\code_table", \ "pcode", "pdesc", "") #searchRows = gp.searchCursor(r"H:\Development\temp\test.mdb\code_table") searchRows = gp.searchCursor(r"L:\SharedData\Denver\Regulatory\GIS\Powder_River_Basin \Pipeline\QAQC_Scripts\test.mdb\code_table") searchRow = searchRows.next() domainList = [] while searchRow: domainList.append(searchRow.pcode) searchRow = searchRows.next() #print domainList try: #Get Workspaces from text file #for line in open("H:/Development/testdata/PRB_POD_Paths.txt", 'r'): #REAL MODE LINE for line in open("L:/SharedData/Denver/Regulatory/GIS/Powder_River_Basin/Pipeline/QA QC_Scripts/PRB_POD_Paths.txt", 'r'): #REAL MODE LINE #for line in open("H:/Development/testdata/workspaces.txt", 'r'): #TEST MODE LINE if not line: break line = line.strip() if not line.startswith("#"): # skip lines that start with # ws, P = line.split("RMP_2_5_",1) #parse line to get path and P_CODE log.write(" " + "\n") log.write(" " + "\n") log.write(P + "\n") print " " print P src = THE_WORKSPACE + line #defines each workspace path #If the Geodatabase exists, perform the operations if os.path.exists(src): #Archive Geodatabase before running script log.write("The Geodatabase exists " + src + "\n") print "The Geodatabase exists " + src archiveFolder = THE_WORKSPACE + ws + "Archive" + "\\" + "RMP_2_5_" + P log.write("archiveFolder is " + archiveFolder + "\n") print "archiveFolder is " + archiveFolder shutil.copy(src, archiveFolder)#Archive the Geodatabase #Set workspace and variables gp.workspace = src log.write(gp.workspace + "\n") print gp.workspace P_Value = (P.strip(".mdb"))
Re: Pyfora, a place for python
>>Daniel Fetchinson writes: > >Probably this thread is going by far too far :) >Ben Finney [ben+pyt...@benfinney.id.au] writes: > Agreed. I was following this discussion first with curiosity and then with increasing disbelief. As a scientist and a programmer, I always considered myself belonging to a group of people who are broad-minded and task-oriented. Being an occasional Python programmer, I subscribed to this list in the hopes of learning from the pros. Most of the time I do. But I also see a disturbing trend of petty bickering, splitting hairs and one-upmanship. I understand there will be occasional language slips and misconstrued jokes but can we please stick to the topic and remain courteous at all times? I am seriously considering unsubscribing from this UL (and maybe joining Pyfora.) -- http://mail.python.org/mailman/listinfo/python-list
Re: executing VBScript from Python and vice versa
A while ago I asked how VBScript can be called from Python. The two answers I received suggested using win32com.client and MSScriptControl.ScriptControl. This solution required embedding the VBScript code inside the Python script. Here's a shell approach that runs an existing VBScript file: Python script import os import sys os.system("F:\Projects\Doc\Scripts\VBScript\WriteDataToTextFile.vbs") VBScript: ' WriteDataToTextFile.vbs Const ForAppending = 8 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile _ ("c:\temp\temp.txt", ForAppending, True) Set objNetwork = CreateObject("Wscript.Network") objComputerName = objNetwork.ComputerName objTextFile.WriteLine("My computer's name is") objTextFile.WriteLine(objComputerName) objTextFile.Close -- http://mail.python.org/mailman/listinfo/python-list
Re: executing VBScript from Python and vice versa
Thanks to Michel Claveau and Paul Paterson for providing examples on how to use ScriptControl to embed VBScript in Python script. I've only tried this once before on another occasion and it was fascinating to see how a function generates another function! Valentina -- http://mail.python.org/mailman/listinfo/python-list
FW: executing VBScript from Python and vice versa
Thanks for the reply. I already have "Learning Python" from Mark Lutz and David Ascher, which covers 2.3 (I am in 2.4). However, it seems like heavy artillery to me. What I want is, for instance, run a VBScript to get a function output and feed it to the Python script that called it. The reason is that because I feel more comfortable with VBScript and have written a small library of useful utilities, I don't want it to become obsolete. In the mean time I did more reading and found a couple of prospective alternatives - popen and os.system(command). Still need to work out how to use them... -Original Message- From: aurora [mailto:[EMAIL PROTECTED] Sent: Friday, February 04, 2005 3:28 PM To: python-list@python.org Subject: Re: executing VBScript from Python and vice versa Go to the bookstore and get a copy of Python Programming on Win32 by Mark Hammond, Andy Robinson today. http://www.oreilly.com/catalog/pythonwin32/ It has everything you need. > Is there a way to make programs written in these two languages > communicate > with each other? I am pretty sure that VBScript can access a Python > script > because Python is COM compliant. On the other hand, Python might be able > to > call a VBScript through WSH. Can somebody provide a simple example? I > have > exactly 4 days of experience in Python (and fortunately, much more in > VB6) > > Thanks. > -- http://mail.python.org/mailman/listinfo/python-list
executing VBScript from Python and vice versa
Is there a way to make programs written in these two languages communicate with each other? I am pretty sure that VBScript can access a Python script because Python is COM compliant. On the other hand, Python might be able to call a VBScript through WSH. Can somebody provide a simple example? I have exactly 4 days of experience in Python (and fortunately, much more in VB6) Thanks. -- http://mail.python.org/mailman/listinfo/python-list