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)
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)
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)
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
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')
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)
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)
def loadCommandModule(cmdName, name): module = importFromString('%s.manage.commands.%s' % (cmdName, name)) return module.Command()
def loadCommandModule(cmdName, name): module = importFromString('.'.join([cmdName, name])) return module.Command()
#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)
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)
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/"