robinburchfield

Python - how to create a success/failure log for each process

Discussion created by robinburchfield on Nov 5, 2015
Latest reply on Nov 6, 2015 by blake.terhune

Hi everyone, a Python and ESRI newbie here.

 

I wish to use a Python script to register a number of Oracle Materialised View with the geodatabase - please see my sample script below.  How can I instruct the script communicate to the user whether each MView has successfully been registered or not, ideally as a log file, or at least an open text file that the user can manually save at the end if they wish?

 

Any guidance would be greatly appreciated

 

Thanks,

 

Robin

 

 

----------START-------------

# -*- coding: utf-8 -*-

# ---------------------------------------------------------------------------

# Reg_MView2.py

# Created on: 2015-11-02 17:30:22.00000

#   (generated by ArcGIS/ModelBuilder)

# Description:

# ---------------------------------------------------------------------------

 

# Set the necessary product code

import arceditor

 

# Import arcpy module

import arcpy

 

# Local variables:

Var1 = "Database Connections\\Connection to GISREF.sde\\GIS.MVIEW1"

Var2 = "Database Connections\\Connection to GISREF.sde\\GIS.MVIEW2"

Var3 = "Database Connections\\Connection to GISREF.sde\\GIS.MVIEW3"

# ....etc

 

# Process: Register with Geodatabase

arcpy.RegisterWithGeodatabase_management(Var1)

arcpy.RegisterWithGeodatabase_management(Var2)

arcpy.RegisterWithGeodatabase_management(Var3)

# ....etc

 

print "Script completed"

-----------END-------

Outcomes