本文整理匯總了Python中app.App方法的典型用法代碼示例。如果您正苦於以下問題:Python app.App方法的具體用法?Python app.App怎麽用?Python app.App使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app
的用法示例。
在下文中一共展示了app.App方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import app [as 別名]
# 或者: from app import App [as 別名]
def main():
parser = argparse.ArgumentParser(
prog='ArtStationDownloader',
description='ArtStation Downloader is a lightweight tool to help you download images and videos from the ArtStation')
parser.add_argument('--version', action='version',
version='%(prog)s '+__version__)
parser.add_argument('-u', '--username',
help='choose who\'s project you want to download, one or more', nargs='*')
parser.add_argument('-d', '--directory', help='output directory')
parser.add_argument(
'-t', '--type', choices=['all', 'image', 'video'], default="all", help='what do you what to download, default is all')
parser.add_argument('-v', '--verbosity', action="count",
help="increase output verbosity")
args = parser.parse_args()
if args.username:
if args.directory:
console = Console()
console.download_by_usernames(args.username, args.directory, args.type)
else:
print("no output directory, please use -d or --directory option to set")
else:
app = App(version=__version__)
app.mainloop() # 進入主循環,程序運行
示例2: sharedwin
# 需要導入模塊: import app [as 別名]
# 或者: from app import App [as 別名]
def sharedwin(sharedapp):
print("@fixture: shared mainwin load...")
app = sharedapp
app.windows["main"].newFromTemplate()
app.windows["main"].show()
yield app.windows
app.windows["main"].editor.setModified(False)
app.windows["main"].close()
print("@fixture: shared mainwin closed.")
# @fixture(scope="function")
# def sharedwin():
# print("@fixture: shared mainwin load...")
# app = App()
# app.run(pytest=True)
# app.windows["main"].newFromTemplate()
# app.windows["main"].show()
# yield app.windows
# app.windows["main"].editor.setModified(False)
# app.windows["main"].close()
# app.quit()
# del app.windows
# del app
# print("@fixture: shared mainwin closed.")
示例3: _update_app_path
# 需要導入模塊: import app [as 別名]
# 或者: from app import App [as 別名]
def _update_app_path():
"""Update sys path to ensure all required modules can be found.
All Apps must be able to access included modules, this method will ensure that the system path
has been updated to include the "cwd" and "lib_" directories. This is normally handled by
the __main__.py file, but in some cases an App may be called directly.
"""
cwd = os.getcwd()
lib_dir = os.path.join(os.getcwd(), 'lib_')
lib_latest = os.path.join(os.getcwd(), 'lib_latest')
# insert the lib_latest directory into the system Path if no other lib directory found. This
# entry will be bumped to index 1 after adding the current working directory.
if not [p for p in sys.path if lib_dir in p]:
sys.path.insert(0, lib_latest)
# insert the current working directory into the system Path for the App, ensuring that it is
# always the first entry in the list.
try:
sys.path.remove(cwd)
except ValueError:
pass
sys.path.insert(0, cwd)
示例4: query
# 需要導入模塊: import app [as 別名]
# 或者: from app import App [as 別名]
def query(self, request):
return App().query(request)
示例5: sharedapp
# 需要導入模塊: import app [as 別名]
# 或者: from app import App [as 別名]
def sharedapp():
print("\n@fixture: shared session Application load...")
app = App()
app.run(pytest=True)
yield app
app.quit()
del app
print("\n@fixture: shared session Application quited.")
示例6: run
# 需要導入模塊: import app [as 別名]
# 或者: from app import App [as 別名]
def run():
"""Update path and run the App."""
# update the path to ensure the App has access to required modules
app_lib = AppLib()
app_lib.update_path()
# import modules after path has been updated
from tcex import TcEx
from app import App
tcex = TcEx()
try:
# load App class
app = App(tcex)
# perform prep/setup operations
app.setup()
# run the App logic
app.run()
# perform cleanup/teardown operations
app.teardown()
# explicitly call the exit method
tcex.exit(msg=app.exit_message)
except Exception as e:
main_err = f'Generic Error. See logs for more details ({e}).'
tcex.log.error(traceback.format_exc())
tcex.playbook.exit(1, main_err)
示例7: run
# 需要導入模塊: import app [as 別名]
# 或者: from app import App [as 別名]
def run():
"""Update path and run the App."""
# update the path to ensure the App has access to required modules
app_lib = AppLib()
app_lib.update_path()
# import modules after path has been updated
from tcex import TcEx
from app import App
tcex = TcEx()
try:
# load App class
app = App(tcex)
# perform prep/setup operations
app.setup()
# run the App logic
if hasattr(app.args, 'tc_action') and app.args.tc_action is not None:
# if the args NameSpace has the reserved arg of "tc_action", this arg value is used to
# triggers a call to the app.<tc_action>() method. an exact match to the method is
# tried first, followed by a normalization of the tc_action value, and finally an
# attempt is made to find the reserved "tc_action_map" property to map value to method.
tc_action = app.args.tc_action
tc_action_formatted = tc_action.lower().replace(' ', '_')
tc_action_map = 'tc_action_map' # reserved property name for action to method map
# run action method
if hasattr(app, tc_action):
getattr(app, tc_action)()
elif hasattr(app, tc_action_formatted):
getattr(app, tc_action_formatted)()
elif hasattr(app, tc_action_map):
app.tc_action_map.get(app.args.tc_action)() # pylint: disable=no-member
else:
tcex.exit(1, f'Action method ({app.args.tc_action}) was not found.')
else:
# default to run method
app.run()
# write requested value for downstream Apps
tcex.playbook.write_output()
app.write_output() # pylint: disable=no-member
# perform cleanup/teardown operations
app.teardown()
# explicitly call the exit method
tcex.playbook.exit(msg=app.exit_message)
except Exception as e:
main_err = f'Generic Error. See logs for more details ({e}).'
tcex.log.error(traceback.format_exc())
tcex.playbook.exit(1, main_err)