Mercurial > sqlpython
changeset 248:230447ce6e60
end wed
author | catherine@dellzilla |
---|---|
date | Tue, 10 Mar 2009 16:42:27 -0400 |
parents | f0f293d83337 |
children | 9e3e49c95abf |
files | sqlpython/sqlpyPlus.py |
diffstat | 1 files changed, 20 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py Wed Mar 04 17:44:29 2009 -0500 +++ b/sqlpython/sqlpyPlus.py Tue Mar 10 16:42:27 2009 -0400 @@ -670,20 +670,22 @@ self.stdout = open(filename, 'w') if vc: subprocess.call(vc + [filename]) - try: - if object_type == 'PACKAGE': - ddl = [['PACKAGE_SPEC', object_name, owner],['PACKAGE_BODY', object_name, owner]] - elif object_type in ['CONTEXT', 'DIRECTORY', 'JOB']: - ddl = [[object_type, object_name]] - else: - ddl = [[object_type, object_name, owner]] - for ddlargs in ddl: + if object_type == 'PACKAGE': + ddl = [['PACKAGE_SPEC', object_name, owner],['PACKAGE_BODY', object_name, owner]] + elif object_type in ['CONTEXT', 'DIRECTORY', 'JOB']: + ddl = [[object_type, object_name]] + else: + ddl = [[object_type, object_name, owner]] + for ddlargs in ddl: + try: self.stdout.write('REMARK BEGIN %s\n%s\nREMARK END\n\n' % (object_name, str(self.curs.callfunc('DBMS_METADATA.GET_DDL', cx_Oracle.CLOB, ddlargs)))) - except cx_Oracle.DatabaseError: - if object_type == 'JOB': - print '%s: DBMS_METADATA.GET_DDL does not support JOBs (MetaLink DocID 567504.1)' % object_name - continue - raise + except cx_Oracle.DatabaseError, errmsg: + if object_type == 'JOB': + print '%s: DBMS_METADATA.GET_DDL does not support JOBs (MetaLink DocID 567504.1)' % object_name + elif 'ORA-31603' in str(errmsg): # not found, as in package w/o package body + pass + else: + raise if opts.full: for dependent_type in ('OBJECT_GRANT', 'CONSTRAINT', 'TRIGGER'): try: @@ -735,6 +737,11 @@ supported_ddl_types = supported_ddl_types.split(', ') def _vc(self, arg, opts, program): + if not os.path.exists('.%s' % program): + create = raw_input('%s repository not yet in current directory (%s). Create (y/N)? ' % + (program, os.getcwd())) + if not create.strip().lower().startswith('y'): + return subprocess.call([program, 'init']) opts.dump = True self._pull(arg, opts, vc=[program, 'add'])