Esempio n. 1
0
    def run(self):
        """Run the sqlobject-admin tool or sacommand module functions."""

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

            if config.get('sqlalchemy.dburi'):
                try:
                    sacommand(command, sys.argv)
                except NoApplicableMethods:
                    sacommand('help', [])
                return

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

            if command 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 command 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')

            socommand.the_runner.run(sys.argv)
Esempio n. 2
0
try:
    pkg_resources.require("TurboGears>=1.5")
except pkg_resources.DistributionNotFound:
    print("""\
This is a TurboGears (http://www.turbogears.org) application. It seems that
you either don't have TurboGears installed or it can not be found.

Please check if your PYTHONPATH is set correctly. To install TurboGears, go to
http://docs.turbogears.org/Install and follow the instructions there. If you
are stuck, visit http://docs.turbogears.org/GettingHelp for support options.""")
    sys.exit(1)
try:
    pkg_resources.require("SQLObject>=1.0.0")
except pkg_resources.DistributionNotFound:
    from turbogears.util import missing_dependency_error
    print missing_dependency_error('SQLObject')
    sys.exit(1)

import cherrypy
import turbogears

from turboaffiliate.release import version

cherrypy.lowercase_api = True

class ConfigurationError(Exception):
    pass

def _read_config(args):
    """Read deployment configuration file.
    
Esempio n. 3
0
from peak.rules import abstract, when, around
from turbogears import config
from turbogears.util import get_model
from turbogears.decorator import simple_decorator
try:
    from sqlalchemy import MetaData, exceptions, Table, String, Unicode
    from turbogears.database import bind_metadata, metadata, get_engine
except ImportError: # if not available, complain only at run-time
    from turbogears.util import missing_dependency_error
    no_sqlalchemy = missing_dependency_error('SQLAlchemy')
else:
    from sqlalchemy import Text, UnicodeText
    no_sqlalchemy = False


@abstract()
def sacommand(command, args):
    pass

@around(sacommand, "command and command != 'help' and no_sqlalchemy")
def no_engine(command, args):
    print no_sqlalchemy

@when(sacommand, "command == 'help'")
def help(command, args):
    print """TurboGears SQLAlchemy Helper

tg-admin sql command [options]

Available commands:
    create  Create tables
Esempio n. 4
0
try:
    pkg_resources.require("TurboGears>=1.1")
except pkg_resources.DistributionNotFound:
    print """\
This is a TurboGears (http://www.turbogears.org) application. It seems that
you either don't have TurboGears installed or it can not be found.

Please check if your PYTHONPATH is set correctly. To install TurboGears, go to
http://docs.turbogears.org/Install and follow the instructions there. If you
are stuck, visit http://docs.turbogears.org/GettingHelp for support options."""
    sys.exit(1)
try:
    pkg_resources.require("SQLAlchemy>=0.4.3")
except pkg_resources.DistributionNotFound:
    from turbogears.util import missing_dependency_error
    print missing_dependency_error('SQLAlchemy')
    sys.exit(1)

import cherrypy
import turbogears

from gordonweb.release import version

cherrypy.lowercase_api = True


class ConfigurationError(Exception):
    pass


def _read_config(args):
Esempio n. 5
0
except pkg_resources.DistributionNotFound:
    print("""\
This is a TurboGears (http://www.turbogears.org) application. It seems that
you either don't have TurboGears installed or it can not be found.

Please check if your PYTHONPATH is set correctly. To install TurboGears, go to
http://docs.turbogears.org/Install and follow the instructions there. If you
are stuck, visit http://docs.turbogears.org/GettingHelp for support options.""")
    sys.exit(1)
try:
    pkg_resources.require("SQLAlchemy>=0.6.0")
    pkg_resources.require("Elixir")
except pkg_resources.DistributionNotFound:
    from turbogears.util import missing_dependency_error

    print missing_dependency_error('SQLAlchemy')
    sys.exit(1)

cherrypy.lowercase_api = True


class ConfigurationError(Exception):
    pass


def _read_config(args):
    """Read deployment configuration file.
    
    First looks on the command line for a desired config file, if it's not on
    the command line, then looks for 'setup.py' in the parent of the directory
    where this module is located.