예제 #1
0
    def handle(self, moduleType, name, *args, **options):
        if not moduleType == 'controller':
            raise CommandError('ない')

        path = options.get('path')
        if path is None:
            currentPath = os.getcwd()
            try:
                importFromString('config')
            except:
                sys.path.append(os.getcwd())
                try:
                    importFromString('config')
                except ImportError:
                    raise CommandError('config file is not found...')
            config = ConfigManager.getConfig(getEnviron())
            path = os.path.join(currentPath, config['APP_DIRECTORY'], config['CONTROLLER_DIRECTORY'])

        if not os.path.isdir(path):
            raise CommandError('Given path is invalid')

        ctrlTemplate = os.path.join(shimehari.__path__[0], 'core', 'conf', 'controller_template.org.py')

        name, filename = self.filenameValidation(path, name)
        newPath = os.path.join(path, filename)

        self.readAndCreateFileWithRename(ctrlTemplate, newPath, name)
예제 #2
0
    def handle(self, moduleType, name, *args, **options):
        if not moduleType == 'controller':
            raise CommandError('ない')

        path = options.get('path')
        if path is None:
            currentPath = os.getcwd()
            try:
                importFromString('config')
            except:
                sys.path.append(os.getcwd())
                try:
                    importFromString('config')
                except ImportError:
                    raise CommandError('config file is not found...')
            config = ConfigManager.getConfig(getEnviron())
            path = os.path.join(currentPath, config['APP_DIRECTORY'],
                                config['CONTROLLER_DIRECTORY'])

        if not os.path.isdir(path):
            raise CommandError('Given path is invalid')

        ctrlTemplate = os.path.join(shimehari.__path__[0], 'core', 'conf',
                                    'controller_template.org.py')

        name, filename = self.filenameValidation(path, name)
        newPath = os.path.join(path, filename)

        self.readAndCreateFileWithRename(ctrlTemplate, newPath, name)
예제 #3
0
 def handle(self, *args, **options):
     try:
         importFromString('config')
     except ImportError:
         sys.path.append(os.getcwd())
         try:
             importFromString('config')
         except ImportError, e:
             t = sys.exc_info()[2]
             raise CommandError(u'コンフィグファイルが見当たりません:: %s' % e), None, traceback.print_tb(t)
예제 #4
0
 def handle(self, *args, **options):
     try:
         importFromString('config')
     except ImportError:
         sys.path.append(os.getcwd())
         try:
             importFromString('config')
         except ImportError, e:
             t = sys.exc_info()[2]
             raise CommandError(u'コンフィグファイルが見当たりません:: %s' %
                                e), None, traceback.print_tb(t)
예제 #5
0
class Command(AbstractCommand):
    name = 'routes'
    summary = "Show Application routing"
    usage = "Usage: %prog [OPTIONS]"

    def __init__(self):
        super(Command, self).__init__()

    def handle(self, *args, **options):
        try:
            importFromString('config')
        except ImportError:
            sys.path.append(os.getcwd())
            try:
                importFromString('config')
            except ImportError, e:
                t = sys.exc_info()[2]
                raise CommandError(u'コンフィグファイルが見当たりません:: %s' %
                                   e), None, traceback.print_tb(t)

        config = ConfigManager.getConfig(getEnviron())
        appPath = os.path.join(os.getcwd(), config['APP_DIRECTORY'])
        if not os.path.isdir(appPath):
            t = sys.exc_info()[2]
            raise CommandError(
                u'アプリケーションが見当たりません::'), None, traceback.print_tb(t)

        try:
            router = importFromString(config['APP_DIRECTORY'] + '.' + 'router')
        except Exception, e:
            t = sys.exc_info()[2]
            raise CommandError(u'ルーターがみつかりません。\n %s' %
                               e), None, traceback.print_tb(t)
예제 #6
0
파일: ds.py 프로젝트: matsumos/toodooo
    def run(self, *args, **options):
        import config

        # try:
        #     #humu-
        #     import config
        # except ImportError, e:
        #     sys.path.append(os.getcwd())
        #     try:
        #         import config
        #     except ImportError, e:
        #         t = sys.exc_info()[2]
        #         raise DrinkError(u'ちょっと頑張ったけどやっぱりコンフィグが見当たりません。\n%s' % e), None, traceback.print_exc(t)

        try:
            currentEnv = options.get('SHIMEHARI_ENV')
            currentConfig = ConfigManager.getConfig(currentEnv or 'development')
            app = importFromString( currentConfig['MAIN_SCRIPT'] + '.' + currentConfig['APP_INSTANCE_NAME'])

            if options.get('browser'):
                timer = threading.Timer(0.5, self.openBrowser, args=[self.host, self.port])
                timer.start()

            app.run(host=self.host, port=int(self.port), debug=True)

        except:
            raise
예제 #7
0
    def handle(self, *args, **options):
        try:
            importFromString('config')
        except ImportError:
            sys.path.append(os.getcwd())
            try:
                importFromString('config')
            except ImportError:
                raise CommandError(u'コンフィグファイルが見当たりません')

        env = options.get('env')
        if env is None:
            env = 'development'

        sys.stdout.write('\nYour Shimehari App Current Config.\n\n')
        sys.stdout.write('-------------------------------------------------\n')
        sys.stdout.write(ConfigManager.getConfig(env).dump())
        sys.stdout.write('\n')
예제 #8
0
    def handle(self, appDir='app', *args, **options):
        try:
            importFromString(appDir)
        except ImportError:
            pass
        else:
            raise CommandError('%s mou aru' % appDir)

        path = options.get('path')
        if path is None:
            appRootDir = os.path.join(os.getcwd(), appDir)
            try:
                os.makedirs(appRootDir)
            except OSError, error:
                if error.errno == errno.EEXIST:
                    msg = '%s is already exists' % appRootDir
                else:
                    msg = error
                raise CommandError(msg)
예제 #9
0
def getTemplater(app, templaterName, *args, **options):
    import shimehari
    templateDir = os.path.join(shimehari.__path__[0], 'template', templaterName)
    if not os.path.isdir(templateDir):
        raise ValueError('template engine not found :: %s\n' % templateDir)
    try:
        module = importFromString('shimehari.template.' + templaterName)
        templater = module.templater
    except Exception, e:
        raise Exception(e)
예제 #10
0
    def handle(self, appDir='app', *args, **options):
        try:
            importFromString(appDir)
        except ImportError:
            pass
        else:
            raise CommandError('%s mou aru' % appDir)

        path = options.get('path')
        if path is None:
            appRootDir = os.path.join(os.getcwd(), appDir)
            try:
                os.makedirs(appRootDir)
            except OSError, error:
                if error.errno == errno.EEXIST:
                    msg = '%s is already exists' % appRootDir
                else:
                    msg = error
                raise CommandError(msg)
예제 #11
0
def getTemplater(app, templaterName, *args, **options):
    import shimehari
    templateDir = os.path.join(shimehari.__path__[0], 'template',
                               templaterName)
    if not os.path.isdir(templateDir):
        raise ValueError('template engine not found :: %s\n' % templateDir)
    try:
        module = importFromString('shimehari.template.' + templaterName)
        templater = module.templater
    except Exception, e:
        raise Exception(e)
예제 #12
0
def loadCommandModule(cmdName, name):
    module = importFromString('%s.manage.commands.%s' % (cmdName, name))
    return module.Command()
예제 #13
0
def loadCommandModule(cmdName, name):
    module = importFromString('.'.join([cmdName, name]))
    return module.Command()
예제 #14
0
            #humu-
            import config
        except ImportError, e:
            sys.path.append(os.getcwd())
            try:
                import config
            except ImportError, e:
                t = sys.exc_info()[2]
                raise DrinkError(u'ちょっと頑張ったけどやっぱりコンフィグが見当たりません。\n%s' % e), None, traceback.print_exc(t)

        try:
            currentEnv = options.get('SHIMEHARI_ENV')
            currentConfig = ConfigManager.getConfig(currentEnv or 'development')

            if len(args):
                app = importFromString(args[0])
            else:
                app = importFromString(currentConfig['APP_DIRECTORY'] + '.' + currentConfig['MAIN_SCRIPT'] + '.' + currentConfig['APP_INSTANCE_NAME'])

            if not self.debug and currentConfig['DEBUG']:
                self.debug = True

            if options.get('browser'):
                timer = threading.Timer(0.5, self.openBrowser, args=[self.host, self.port])
                timer.start()

            # key = KeywordListenerThread()
            # key.register(KeywordCallback(self.openBrowser, [self.host, self.port]), 'b', 'browser')
            # key.start()

            app.drink(host=self.host, port=int(self.port), debug=self.debug)
예제 #15
0
        except ImportError, e:
            import sys
            sys.path.append(os.getcwd())
            try:
                import config
            except ImportError, e:
                t = sys.exc_info()[2]
                raise DrinkError(u'ちょっと頑張ったけどやっぱりコンフィグが見当たりません。\n%s' %
                                 e), None, traceback.print_exc(t)

        try:
            currentEnv = options.get('SHIMEHARI_ENV')
            currentConfig = ConfigManager.getConfig(currentEnv
                                                    or 'development')
            app = importFromString(currentConfig['APP_DIRECTORY'] + '.' +
                                   currentConfig['MAIN_SCRIPT'] + '.' +
                                   currentConfig['APP_INSTANCE_NAME'])
            if not self.debug and currentConfig['DEBUG']:
                self.debug = True

            def openBrowser(host, port):
                url = 'http://'
                if not host:
                    url += '127.0.0.1'
                else:
                    url += host

                if not port:
                    url += ':5959/'
                else:
                    url += ':' + str(port)
예제 #16
0
def loadCommandModule(cmdName, name):
    module = importFromString('%s.manage.commands.%s' % (cmdName, name))
    return module.Command()
예제 #17
0
            import sys

            sys.path.append(os.getcwd())
            try:
                import config
            except ImportError, e:
                t = sys.exc_info()[2]
                raise DrinkError(u"ちょっと頑張ったけどやっぱりコンフィグが見当たりません。\n%s" % e), None, traceback.print_exc(t)

        try:
            currentEnv = options.get("SHIMEHARI_ENV")
            currentConfig = ConfigManager.getConfig(currentEnv or "development")
            app = importFromString(
                currentConfig["APP_DIRECTORY"]
                + "."
                + currentConfig["MAIN_SCRIPT"]
                + "."
                + currentConfig["APP_INSTANCE_NAME"]
            )
            if not self.debug and currentConfig["DEBUG"]:
                self.debug = True

            def openBrowser(host, port):
                url = "http://"
                if not host:
                    url += "127.0.0.1"
                else:
                    url += host

                if not port:
                    url += ":5959/"