Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
8afa3a30
Kaydet (Commit)
8afa3a30
authored
Ock 04, 2003
tarafından
Just van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
module to run commands in a Terminal.app window
üst
75a6e3bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
terminalcommand.py
Lib/plat-mac/terminalcommand.py
+54
-0
No files found.
Lib/plat-mac/terminalcommand.py
0 → 100644
Dosyayı görüntüle @
8afa3a30
"""terminalcommand.py -- A minimal interface to Terminal.app.
To run a shell command in a new Terminal.app window:
import terminalcommand
terminalcommand.run("ls -l")
No result is returned; it is purely meant as a quick way to run a script
with a decent input/output window.
"""
#
# This module is a fairly straightforward translation of Jack Jansen's
# Mac/OSX/PythonLauncher/doscript.m.
#
import
time
import
os
from
Carbon
import
AE
from
Carbon.AppleEvents
import
*
TERMINAL_SIG
=
"trmx"
START_TERMINAL
=
"/usr/bin/open /Applications/Utilities/Terminal.app"
SEND_MODE
=
kAENoReply
# kAEWaitReply hangs when run from Terminal.app itself
def
run
(
command
):
"""Run a shell command in a new Terminal.app window."""
termAddress
=
AE
.
AECreateDesc
(
typeApplSignature
,
TERMINAL_SIG
)
theEvent
=
AE
.
AECreateAppleEvent
(
kAEMiscStandards
,
kAEActivate
,
termAddress
,
kAutoGenerateReturnID
,
kAnyTransactionID
)
try
:
theEvent
.
AESend
(
SEND_MODE
,
kAENormalPriority
,
kAEDefaultTimeout
)
except
AE
.
Error
,
why
:
if
why
[
0
]
!=
-
600
:
# Terminal.app not yet running
raise
os
.
system
(
START_TERMINAL
)
time
.
sleep
(
1
)
theEvent
.
AESend
(
SEND_MODE
,
kAENormalPriority
,
kAEDefaultTimeout
)
theEvent
=
AE
.
AECreateAppleEvent
(
kAECoreSuite
,
kAEDoScript
,
termAddress
,
kAutoGenerateReturnID
,
kAnyTransactionID
)
commandDesc
=
AE
.
AECreateDesc
(
typeChar
,
command
)
theEvent
.
AEPutParamDesc
(
kAECommandClass
,
commandDesc
)
theEvent
.
AESend
(
SEND_MODE
,
kAENormalPriority
,
kAEDefaultTimeout
)
if
__name__
==
"__main__"
:
run
(
"ls -l"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment