예제 #1
0
    def run(self):
        """Run the sqlobject-admin tool or functions from the sacommand module."""

        if not "--egg" in sys.argv and not gearshift.util.get_project_name():
            print "This doesn't look like a GearShift project."
            return
        else:
            command = sys.argv[1]

            if config.get("sqlalchemy.dburi"):
                try:
                    sacommand(command, sys.argv)
                except Exception:  # NoApplicableMethods:
                    # Anonymous except to avoid making entire
                    # gearshift dependent on peak.rules just to get
                    # this ONE case of NoApplicableMethods...
                    sacommand("help", [])
                return

            try:
                from sqlobject.manager import command
            except ImportError:
                from gearshift.util import missing_dependency_error
                print missing_dependency_error('SQLObject')
                return

            sqlobjcommand = command
            if sqlobjcommand not in no_connection_param:
                if self.dburi:
                    print "Using database URI %s" % self.dburi
                    sys.argv.insert(2, self.dburi)
                    sys.argv.insert(2, "-c")
                else:
                    print(
                        "Database URI not specified in the config file"
                        " (%s).\nPlease be sure it's on the command line." %
                        (self.config or get_project_config()))

            if sqlobjcommand not in no_model_param:
                if not "--egg" in sys.argv:
                    eggname = glob.glob("*.egg-info")
                    if not eggname or not os.path.exists(
                            os.path.join(eggname[0], "sqlobject.txt")):
                        eggname = self.fix_egginfo(eggname)
                    eggname = eggname[0].replace(".egg-info", "")
                    if not "." in sys.path:
                        sys.path.append(".")
                        pkg_resources.working_set.add_entry(".")
                    sys.argv.insert(2, eggname)
                    sys.argv.insert(2, "--egg")

            command.the_runner.run(sys.argv)
예제 #2
0
    def run(self):
        """Run the sqlobject-admin tool or functions from the sacommand module."""

        if not "--egg" in sys.argv and not gearshift.util.get_project_name():
            print "This doesn't look like a GearShift project."
            return
        else:
            command = sys.argv[1]

            if config.get("sqlalchemy.dburi"):
                try:
                    sacommand(command, sys.argv)
                except Exception: # NoApplicableMethods:
                    # Anonymous except to avoid making entire
                    # gearshift dependent on peak.rules just to get
                    # this ONE case of NoApplicableMethods...
                    sacommand("help", [])
                return

            try:
                from sqlobject.manager import command
            except ImportError:
                from gearshift.util import missing_dependency_error
                print missing_dependency_error('SQLObject')
                return

            sqlobjcommand = command
            if sqlobjcommand not in no_connection_param:
                if self.dburi:
                    print "Using database URI %s" % self.dburi
                    sys.argv.insert(2, self.dburi)
                    sys.argv.insert(2, "-c")
                else:
                    print ("Database URI not specified in the config file"
                        " (%s).\nPlease be sure it's on the command line."
                            % (self.config or get_project_config()))

            if sqlobjcommand not in no_model_param:
                if not "--egg" in sys.argv:
                    eggname = glob.glob("*.egg-info")
                    if not eggname or not os.path.exists(
                            os.path.join(eggname[0], "sqlobject.txt")):
                        eggname = self.fix_egginfo(eggname)
                    eggname = eggname[0].replace(".egg-info", "")
                    if not "." in sys.path:
                        sys.path.append(".")
                        pkg_resources.working_set.add_entry(".")
                    sys.argv.insert(2, eggname)
                    sys.argv.insert(2, "--egg")

            command.the_runner.run(sys.argv)
예제 #3
0
from gearshift import config
from gearshift.util import get_model
from gearshift.decorator import simple_decorator
try:
    from sqlalchemy import MetaData, exceptions, Table, String, Unicode
    from gearshift.database import bind_metadata, metadata, get_engine
except ImportError:  # if not available, complain only at run-time
    from gearshift.util import missing_dependency_error
    no_sqlalchemy = missing_dependency_error('SQLAlchemy')
else:
    try:
        from sqlalchemy import Text, UnicodeText
    except ImportError:  # SQLAlchemy < 0.4.3
        Text, UnicodeText = String, Unicode
    no_sqlalchemy = False


def no_engine(command, args):
    print no_sqlalchemy


def help(command, args):
    print """TurboGears SQLAlchemy Helper

tg-admin sql command [options]

Available commands:
    create  Create tables
    execute Execute SQL statements
    help    Show help
    list    List tables that appear in the model
예제 #4
0
from gearshift import config
from gearshift.util import get_model
from gearshift.decorator import simple_decorator
try:
    from sqlalchemy import MetaData, exceptions, Table, String, Unicode
    from gearshift.database import bind_metadata, metadata, get_engine
except ImportError: # if not available, complain only at run-time
    from gearshift.util import missing_dependency_error
    no_sqlalchemy = missing_dependency_error('SQLAlchemy')
else:
    try:
        from sqlalchemy import Text, UnicodeText
    except ImportError: # SQLAlchemy < 0.4.3
        Text, UnicodeText = String, Unicode
    no_sqlalchemy = False

def no_engine(command, args):
    print no_sqlalchemy

def help(command, args):
    print """TurboGears SQLAlchemy Helper

tg-admin sql command [options]

Available commands:
    create  Create tables
    execute Execute SQL statements
    help    Show help
    list    List tables that appear in the model
    status  Show differences between model and database
"""