def setUpClass(self): self.sdeconn = os.environ['SDEFILE'] self.geodatabase = gdb.Gdb() self.version = version.Version(self.geodatabase ,'TEST_VERSION') self.version.delete()
def test_aainit(self): initsucceeded = True try: os.environ['SDEFILE'] = 'C:/Temp/badsde.sde' self.badgeodatabase = gdb.Gdb() initsucceeded = True except: initsucceeded = False finally: os.environ['SDEFILE'] = self.sdeconn self.assertFalse(initsucceeded)
def setUpClass(self): self.sdeconn = os.environ['SDEFILE'] self.testgdb = gdb.Gdb() # c:\matt_projects\geodatabase-toiler\src\py\testdata\testdata.gpkg\main.BUILDING self.srctestfcdir = os.getcwd() + r'\\src\\py\\testdata\\' self.srctestfc = self.srctestfcdir + r'testdata.gpkg\main.BUILDING' self.testgdb.importfeatureclass(self.srctestfc ,'TOILERTESTFC') self.testfc = fc.Fc(self.testgdb ,'TOILERTESTFC') #get some non-oracle managed user on the DB to work with self.dummyuser = cx_sde.selectavalue(self.testgdb.sdeconn ,self.testgdb.fetchsql('dummyuser.sql'))
"""Enable versioned views from ArcGIS (python 27) """ import os import sys # these are the skeleton 2.7 classes here in py27 import gdb import fc # C:\matt_projects\geodatabase-toiler>set SDEFILE=XX:\GIS\Internal\Connections\oracle19c\dev\bldg.sde # no arcpy2path environmental, we are already being called from the oldskool py27\python.exe fcname = sys.argv[1] gdb27 = gdb.Gdb() fc27 = fc.Fc(gdb27, fcname) fc27.createversionedviews()
def setUpClass(self): self.sdeconn = os.environ['SDEFILE'] self.geodatabase = gdb.Gdb()
"""Enable gdb from ArcGIS (python 27) """ import os import gdb # C:\matt_projects\geodatabase-toiler>set SDEFILE=XX:\GIS\Internal\Connections\oracle19c\dev\GIS-ditGSdv1\mschell_private\mschell.sde # C:\matt_projects\geodatabase-toiler>set AUTHFILE=XX:\GIS\Internal\Connections\oracle19c\dev\GIS-ditGSdv1\mschell_private\keycodes # no arcpy2path environmental, we are already being called from the oldskool py27 authfile = os.environ['AUTHFILE'] baby27gdb = gdb.Gdb() baby27gdb.enable(authfile)
except ImportError: importsuccess = False content = 'Unknown if ESRI geodatabase on {0} is reachable. Module import failure. '.format( sdeconn) msg['Subject'] = 'Indeterminate ESRI Geodatabase' success = False if importsuccess: try: # failures will be in initialization # do not use gdb2test outside of this block, it may be undefined gdb2test = gdb.Gdb() if not gdb2test.checkconnection(): success = False else: success = True except: success = False if success: content = 'ESRI geodatabase on {0} is reachable '.format(sdeconn) msg['Subject'] = 'Reachable ESRI Geodatabase' else: content = 'ESRI geodatabase on {0} is unreachable '.format(sdeconn) msg['Subject'] = 'Unreachable ESRI Geodatabase'
files.append(os.path.abspath(f)) elif os.path.isdir(f): files += map(os.path.abspath, glob.glob(f + '/*')) print("Found %d files" % len(files)) tmpdir = tempfile.mkdtemp() def cleanup(): shutil.rmtree(tmpdir) os.chdir(FUZZDIR) g = gdb.Gdb(FUZZBIN, timeout=10) g.setup() todo = [] for f in files: h = check_output(['sha1sum', f]).split(b' ')[0].decode('utf-8') crashname = ROOTDIR + '/crashes/' + h + '.bsp' if not os.path.exists(crashname): todo.append((f, h)) print("TODO %d files" % len(todo)) random.shuffle(todo) cnt = 0 for fname, h in todo: cnt += 1
timestr = time.strftime("%Y%m%d-%H%M%S") targetlog = os.path.join(os.environ['TARGETLOGDIR'] ,'enablegdb-{0}.log'.format(timestr)) logging.basicConfig(filename=targetlog ,level=logging.INFO) logging.info('Starting enable_gdb log') authfile = os.environ['AUTHFILE'] # not SOP, we only need this for enablement arcpy2path = os.environ['ARCPY2PATH'] # initialize with optional py27 path babygdb = gdb.Gdb(arcpy2path) babygdb.spoolsql('start') #enable using this keycodes file try: babygdb.enable(authfile) exitcode = 0 except: exitcode = 1 finally: babygdb.spoolsql('stop') logging.info('Completed enabling gdb, exit code is {0}'.format(exitcode)) exit(exitcode)