本文整理汇总了Python中appscript.app函数的典型用法代码示例。如果您正苦于以下问题:Python app函数的具体用法?Python app怎么用?Python app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了app函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_delete
def _do_delete(self, j, *args):
def op(dupe):
j.add_progress()
return self._do_delete_dupe(dupe, *args)
self.deleted_aperture_photos = False
marked = [dupe for dupe in self.results.dupes if self.results.is_marked(dupe)]
j.start_job(self.results.mark_count, tr("Sending dupes to the Trash"))
if any(isinstance(dupe, IPhoto) for dupe in marked):
j.add_progress(0, desc=tr("Talking to iPhoto. Don't touch it!"))
try:
a = app("iPhoto")
a.activate(timeout=0)
a.select(a.photo_library_album(timeout=0), timeout=0)
except (CommandError, RuntimeError, ApplicationNotFoundError):
pass
if any(isinstance(dupe, AperturePhoto) for dupe in marked):
self.deleted_aperture_photos = True
j.add_progress(0, desc=tr("Talking to Aperture. Don't touch it!"))
try:
a = app("Aperture")
a.activate(timeout=0)
except (CommandError, RuntimeError, ApplicationNotFoundError):
pass
self.results.perform_on_marked(op, True)
示例2: import_transaction_file
def import_transaction_file(self, transaction_file_path):
self.browser.execute_script("AppMessenger.fireEvent('panelchanged', 1);") # transacoes
time.sleep(5)
elem = self.browser.find_elements_by_xpath("//*[contains(@class,'x-btn x-importar x-btn-noicon')]") # importar
elem[0].click()
elem = self.browser.find_element_by_xpath("//b[contains(text(),'Avan')]") # avancar
elem.click()
elem = self.browser.find_element_by_name("file")
elem.send_keys(transaction_file_path)
elem = self.browser.find_elements_by_xpath("//*[contains(@class,'x-form-trigger x-form-arrow-trigger')]")
elem[7].click()
app('Firefox').activate()
app('System Events').keystroke('\r')
elem = self.browser.find_element_by_xpath("//b[contains(text(),'Avan')]") # avancar
elem.click()
time.sleep(20) # uploading...
elem = self.browser.find_elements_by_link_text("aqui") # clicking at aqui link
elem[0].click()
elem = self.browser.find_elements_by_xpath("//*[contains(text(),'Importar arquivo')]") # clicar no importar arquivo
elem[-1].click()
time.sleep(20)
示例3: PUT
def PUT(self, new_playlist):
"""Modifies the tracks in an iTunes playlist"""
if self.special:
raise error.InvalidRequestError("Attempted to change special playlist '%s'" % self.ref.name)
new_tracks = new_playlist['playlist']['tracks']
new_ids = [track["track"]["id"] for track in new_tracks]
try:
current_ids = self.ref.tracks.persistent_ID.get()
except CommandError:
current_ids = []
#remove all tracks no longer in list
for i, current_id in enumerate(current_ids):
if not new_ids.count(current_id):
self.ref.tracks[its.persistent_ID == current_id].delete()
del current_ids[i]
#add all new tracks to list
for new_id in new_ids:
if not current_ids.count(new_id):
new_track = app('iTunes').user_playlists['Music'].file_tracks[its.persistent_ID == new_id].first()
app('iTunes').duplicate(new_track, to=self.ref)
#rearrange new list
for index, track_id in enumerate(new_ids):
location_reference = self.ref.tracks[index+1].before
track = self.ref.tracks[its.persistent_ID == track_id].first()
app('iTunes').move(track,to=location_reference)
self.tracks = [Track(track_ref = x) for x in self.ref.file_tracks.get()]
示例4: new
def new(self,url=None):
"""make and return new window"""
app("Safari").make(new=k.document)
r=app("Safari").windows.first
if url:
window(r).current_tab.url=url
return window(r)
示例5: help
def help(constructor, identity, style, flags, aemreference, commandname=''):
id = (constructor, identity, style)
if id not in _cache:
if constructor == 'path':
appobj = appscript.app(identity)
elif constructor == 'pid':
appobj = appscript.app(pid=identity)
elif constructor == 'url':
appobj = appscript.app(url=identity)
elif constructor == 'aemapp':
appobj = appscript.app(aemapp=aem.Application(desc=identity))
elif constructor == 'current':
appobj = appscript.app()
else:
raise RuntimeError, 'Unknown constructor: %r' % constructor
output = StringIO()
helpobj = Help(appobj, style, output)
_cache[id] = (appobj, helpobj, output)
ref, helpobj, output = _cache[id]
output.truncate(0)
if aemreference is not None:
ref = ref.AS_newreference(aemreference)
if commandname:
ref = getattr(ref, commandname)
helpobj.help(flags, ref)
s = output.getvalue()
if NSUserDefaults.standardUserDefaults().boolForKey_(u'enableLineWrap'):
res = []
textwrapper = textwrap.TextWrapper(width=NSUserDefaults.standardUserDefaults().integerForKey_(u'lineWrap'),
subsequent_indent=' ' * 12)
for line in s.split('\n'):
res.append(textwrapper.fill(line))
s = u'\n'.join(res)
return s
示例6: start_scanning
def start_scanning(self):
if self.directories.has_itunes_path():
try:
app(ITUNES, terms=tunes)
except ApplicationNotFoundError:
self.view.show_message(tr("The iTunes application couldn't be found."))
return
DupeGuruBase.start_scanning(self)
示例7: start_scanning
def start_scanning(self):
if self.directories.has_iphoto_path():
try:
app("iPhoto")
except ApplicationNotFoundError:
self.view.show_message(tr("The iPhoto application couldn't be found."))
return
DupeGuruBase.start_scanning(self)
示例8: _set_position
def _set_position(self, value):
try:
duration = app('iTunes').current_track.duration()
if value > duration or value < 0:
raise error.InvalidRequestError("Track position %s is not valid" % value)
app('iTunes').player_position.set(value)
except CommandError:
raise error.InvalidRequestError("Cannot set position when iTunes has no current track.")
示例9: special_key
def special_key(self, key, using=None):
"""send non printable key
using is list of special key like:
['control_down', 'command_down', 'option_down']
"""
sp_keys = [ getattr(appscript.k, sp_key) for sp_key in using if hasattr(appscript.k, sp_key) ]
appscript.app('System Events').keystroke(key , using=sp_keys)
示例10: set_wallpaper
def set_wallpaper(image_file_with_path):
filepath = os.path.abspath(image_file_with_path)
try:
app('Finder').desktop_picture.set(mactypes.File(filepath))
return True
except Exception:
return False
示例11: reset_status_bar
def reset_status_bar():
"""
Since Apple Script cannot access Excel while a Macro is running, we have to run the Python call in a
background process which makes the call return immediately: we rely on the StatusBar to give the user
feedback.
This function is triggered when the interpreter exits and makes sure that the StatusBar in Excel is
reset. Due to a bug in Apple Script, False doesn't reset it properly so we're calling it through an
Excel Macro to get it right.
"""
app('Microsoft Excel').run_VB_macro('ResetStatusBar')
示例12: test_by_id
def test_by_id(self):
for name in ["com.apple.textedit", "com.apple.finder"]:
a = appscript.app(id=name)
self.assertNotEqual(None, a)
self.assertEqual(appscript.reference.Application, a.__class__)
self.assertEqual(appscript.reference.Reference, a.name.__class__)
self.assertEqual("app(u'/Applications/TextEdit.app')", str(appscript.app(id="com.apple.textedit")))
self.assertRaises(appscript.ApplicationNotFoundError, appscript.app, id="non.existent.app")
示例13: clean_up
def clean_up():
"""
Since AppleScript cannot access Excel while a Macro is running, we have to run the Python call in a
background process which makes the call return immediately: we rely on the StatusBar to give the user
feedback.
This function is triggered when the interpreter exits and runs the CleanUp Macro in VBA to show any
errors and to reset the StatusBar.
"""
if is_excel_running():
app('Microsoft Excel').run_VB_macro('CleanUp')
示例14: mate
def mate(self):
frame, lineno = self.stack[self.curindex]
filename = self.canonic(frame.f_code.co_filename)
if exists(filename):
tm_url = 'txmt://open?url=file://%s&line=%d&column=2' % (filename, lineno)
if have_appscript:
app("TextMate").get_url(tm_url)
else:
osa_cmd = 'tell application "TextMate" to get url "%s"' % tm_url
system('osascript -e \'%s\'' % osa_cmd)
示例15: get_workbook
def get_workbook(fullname):
"""
Get the appscript Workbook object.
On Mac, it seems that we don't have to deal with >1 instances of Excel,
as each spreadsheet opens in a separate window anyway.
"""
filename = os.path.basename(fullname)
xl_workbook = app('Microsoft Excel').workbooks[filename]
xl_app = app('Microsoft Excel')
return xl_app, xl_workbook