本文整理汇总了Python中console.Console.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Console.execute方法的具体用法?Python Console.execute怎么用?Python Console.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类console.Console
的用法示例。
在下文中一共展示了Console.execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from console import Console [as 别名]
# 或者: from console.Console import execute [as 别名]
class Application:
entitylist = [[],[],[]] # 2D array - [0] er bak, [1] er player, [2] er forran
def __init__(self):
self.width = getWidth()
self.height = getHeight()
self.fps = getFPS()
self.bubbleCount = int(getWidth() / 160)
self.drawBubbles = True
self.drawBG = True
pygame.init()
self.fpsClock = pygame.time.Clock()
if fullscreen():
self.windowSurfaceObj = pygame.display.set_mode((self.width, self.height), pygame.FULLSCREEN)
else:
self.windowSurfaceObj = pygame.display.set_mode((self.width, self.height))
pygame.display.set_caption('Anim')
pygame.mouse.set_visible(cursor())
for i in range(0, self.bubbleCount):
self.entitylist[2].append(Bubble(True))
self.entitylist[0].append(Bubble(False))
self.player = Player()
self.entitylist[1].append(self.player)
self.background = Background()
print('Init...')
self.console = Console(getWidth(), getHeight())
Console.host = self
self.DrawPosVector = False
def event(self):
self.events = pygame.event.get()
for event in self.events:
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYUP:
if event.key == K_ESCAPE:
print('Exiting...')
self.exit()
if event.type == KEYDOWN:
if event.key == K_F12:
self.console.toggle()
elif self.console.isActive():
if event.key == K_RETURN:
self.console.execute()
break
elif event.key == K_BACKSPACE:
self.console.setCurrentLine(self.console.getCurrentLine()[:-1])
break
self.console.appendCurrentLine(event.unicode)
return
self.background.dirVector.setX(-(self.player.getXSpeed() / 8))
self.background.event(self.events)
for lst in self.entitylist:
for e in lst:
if isinstance(e, Bubble):
e.setXSpeedFromPlayer(-self.player.getXSpeed())
e.event(self.events)
def render(self):
#Background
if self.drawBG: self.background.render(self.windowSurfaceObj)
for lst in self.entitylist:
for e in lst:
e.render(self.windowSurfaceObj, self.DrawPosVector)
#Konsollen
self.console.render(self.windowSurfaceObj)
pygame.display.update()
self.fpsClock.tick(getFPS())
def exit(self):
pygame.event.post(pygame.event.Event(QUIT))
def fullscreen(self, input):
if input:
self.windowSurfaceObj = pygame.display.set_mode((self.width, self.height), pygame.FULLSCREEN)
else:
self.windowSurfaceObj = pygame.display.set_mode((self.width, self.height))
示例2: __init__
# 需要导入模块: from console import Console [as 别名]
# 或者: from console.Console import execute [as 别名]
class Deploy:
def __init__(self):
self.config = Conf()
self.console = Console()
def path(self, option):
path = self.config.get(option)
return os.path.abspath(path);
def chown(self, path):
user = self.config.get('deploy_user')
self.console.run(['chown', '-R', user, path])
def linkdir(self, src, dst):
self.console.run(['ln', '-sfn', src, dst])
def version(self, deploy_path):
hash = self.console.run(['git', 'rev-parse', 'HEAD'], cwd=deploy_path);
return hash[0:8]
def hostname(self):
hostname = self.console.run(['hostname', '-f'], output=False);
return hostname
def sync(self, src, dst):
if os.path.exists(src) == False:
os.makedirs(src, 0755)
self.console.run([
'rsync',
'--links',
'--checksum',
'--whole-file',
'--recursive',
src.rstrip('/') + '/',
dst
])
def checkout(self):
deploy_path = self.path('release_path') + '/' + time.strftime('%Y%m%d%H%M%S')
if os.path.exists(deploy_path) == False:
os.makedirs(deploy_path, 0755)
gitclone = ' '.join([
'git',
'clone',
'--quiet',
'--recursive',
'--depth', '1',
'--branch', self.config.get('repo_branch'),
self.config.get('repo_url'),
deploy_path
])
sshadd = ' '.join([
'ssh-add',
self.config.get('deploy_key')
])
self.console.success('Fetching files')
self.console.execute('ssh-agent sh -c \'' + sshadd + '; ' + gitclone + '\'')
return deploy_path
def composer(self, deploy_path):
if os.path.exists(deploy_path + '/composer.json') == False:
return None
self.console.success('Installing composer dependencies')
self.console.run([
'composer',
'--quiet',
'--no-interaction',
'install',
'--prefer-dist',
'--no-dev',
'--optimize-autoloader'
], cwd=deploy_path);
def scripts(self, scripts_to_run, deploy_path):
if self.config.has(scripts_to_run) == False:
return
scripts = self.config.get(scripts_to_run)
for line in scripts:
command = line.replace('$deploy_path', deploy_path)
command = command.replace('$repo_branch', self.config.get('repo_branch'))
command = command.replace('$repo_url', self.config.get('repo_url'))
command = command.replace('$hostname', self.hostname())
self.console.run(shlex.split(command), cwd=deploy_path)
def clean(self):
release_path = self.path('release_path')
deployments = self.console.run(['ls', '-1tA', release_path])
deploys_to_keep = int(self.config.get('deploys_to_keep'))
for folder in deployments.splitlines()[deploys_to_keep:]:
#.........这里部分代码省略.........