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
7fd29f01
Kaydet (Commit)
7fd29f01
authored
May 02, 2008
tarafından
Ronald Oussoren
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Backport of revision 62648
üst
f3bb2839
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
101 deletions
+43
-101
AppleEvents.py
Lib/plat-mac/Carbon/AppleEvents.py
+1
-0
terminalcommand.py
Lib/plat-mac/terminalcommand.py
+1
-1
doscript.m
Mac/PythonLauncher/doscript.m
+41
-100
No files found.
Lib/plat-mac/Carbon/AppleEvents.py
Dosyayı görüntüle @
7fd29f01
# Generated from 'AEDataModel.h'
# Generated from 'AEDataModel.h'
def
FOUR_CHAR_CODE
(
x
):
return
x
def
FOUR_CHAR_CODE
(
x
):
return
x
typeApplicationBundleID
=
FOUR_CHAR_CODE
(
'bund'
)
typeBoolean
=
FOUR_CHAR_CODE
(
'bool'
)
typeBoolean
=
FOUR_CHAR_CODE
(
'bool'
)
typeChar
=
FOUR_CHAR_CODE
(
'TEXT'
)
typeChar
=
FOUR_CHAR_CODE
(
'TEXT'
)
typeSInt16
=
FOUR_CHAR_CODE
(
'shor'
)
typeSInt16
=
FOUR_CHAR_CODE
(
'shor'
)
...
...
Lib/plat-mac/terminalcommand.py
Dosyayı görüntüle @
7fd29f01
...
@@ -27,7 +27,7 @@ SEND_MODE = kAENoReply # kAEWaitReply hangs when run from Terminal.app itself
...
@@ -27,7 +27,7 @@ SEND_MODE = kAENoReply # kAEWaitReply hangs when run from Terminal.app itself
def
run
(
command
):
def
run
(
command
):
"""Run a shell command in a new Terminal.app window."""
"""Run a shell command in a new Terminal.app window."""
termAddress
=
AE
.
AECreateDesc
(
typeAppl
Signature
,
TERMINAL_SIG
)
termAddress
=
AE
.
AECreateDesc
(
typeAppl
icationBundleID
,
"com.apple.Terminal"
)
theEvent
=
AE
.
AECreateAppleEvent
(
kAECoreSuite
,
kAEDoScript
,
termAddress
,
theEvent
=
AE
.
AECreateAppleEvent
(
kAECoreSuite
,
kAEDoScript
,
termAddress
,
kAutoGenerateReturnID
,
kAnyTransactionID
)
kAutoGenerateReturnID
,
kAnyTransactionID
)
commandDesc
=
AE
.
AECreateDesc
(
typeChar
,
command
)
commandDesc
=
AE
.
AECreateDesc
(
typeChar
,
command
)
...
...
Mac/PythonLauncher/doscript.m
Dosyayı görüntüle @
7fd29f01
...
@@ -11,108 +11,49 @@
...
@@ -11,108 +11,49 @@
#import <ApplicationServices/ApplicationServices.h>
#import <ApplicationServices/ApplicationServices.h>
#import "doscript.h"
#import "doscript.h"
/* I assume I could pick these up from somewhere, but where... */
#define CREATOR 'trmx'
#define ACTIVATE_CMD 'misc'
#define ACTIVATE_SUITE 'actv'
#define DOSCRIPT_CMD 'dosc'
#define DOSCRIPT_SUITE 'core'
#define WITHCOMMAND 'cmnd'
/* ... and there's probably also a better way to do this... */
#define START_TERMINAL "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal &"
extern
int
extern
int
doscript
(
const
char
*
command
)
doscript
(
const
char
*
command
)
{
{
OSErr
err
;
char
*
bundleID
=
"com.apple.Terminal"
;
AppleEvent
theAEvent
,
theReply
;
AppleEvent
evt
,
res
;
AEAddressDesc
terminalAddress
;
AEDesc
desc
;
AEDesc
commandDesc
;
OSStatus
err
;
OSType
terminalCreator
=
CREATOR
;
[[
NSWorkspace
sharedWorkspace
]
launchApplication
:
@"/Applications/Utilities/Terminal.app/"
];
/* set up locals */
AECreateDesc
(
typeNull
,
NULL
,
0
,
&
theAEvent
);
// Build event
AECreateDesc
(
typeNull
,
NULL
,
0
,
&
terminalAddress
);
err
=
AEBuildAppleEvent
(
kAECoreSuite
,
kAEDoScript
,
AECreateDesc
(
typeNull
,
NULL
,
0
,
&
theReply
);
typeApplicationBundleID
,
AECreateDesc
(
typeNull
,
NULL
,
0
,
&
commandDesc
);
bundleID
,
strlen
(
bundleID
),
kAutoGenerateReturnID
,
/* create the "activate" event for Terminal */
kAnyTransactionID
,
err
=
AECreateDesc
(
typeApplSignature
,
(
Ptr
)
&
terminalCreator
,
&
evt
,
NULL
,
sizeof
(
terminalCreator
),
&
terminalAddress
);
"'----':utf8(@)"
,
strlen
(
command
),
if
(
err
!=
noErr
)
{
command
);
NSLog
(
@"doscript: AECreateDesc: error %d
\n
"
,
err
);
if
(
err
)
{
goto
bail
;
NSLog
(
@"AEBuildAppleEvent failed: %d
\n
"
,
err
);
}
return
err
;
err
=
AECreateAppleEvent
(
ACTIVATE_SUITE
,
ACTIVATE_CMD
,
}
&
terminalAddress
,
kAutoGenerateReturnID
,
kAnyTransactionID
,
&
theAEvent
);
// Send event and check for any Apple Event Manager errors
err
=
AESendMessage
(
&
evt
,
&
res
,
kAEWaitReply
,
kAEDefaultTimeout
);
if
(
err
!=
noErr
)
{
AEDisposeDesc
(
&
evt
);
NSLog
(
@"doscript: AECreateAppleEvent(activate): error %d
\n
"
,
err
);
if
(
err
)
{
goto
bail
;
NSLog
(
@"AESendMessage failed: %d
\n
"
,
err
);
}
return
err
;
/* send the event */
}
err
=
AESend
(
&
theAEvent
,
&
theReply
,
kAEWaitReply
,
// Check for any application errors
kAENormalPriority
,
kAEDefaultTimeout
,
NULL
,
NULL
);
err
=
AEGetParamDesc
(
&
res
,
keyErrorNumber
,
typeSInt32
,
&
desc
);
if
(
err
==
-
600
)
{
AEDisposeDesc
(
&
res
);
int
count
=
10
;
if
(
!
err
)
{
/* If it failed with "no such process" try to start Terminal */
AEGetDescData
(
&
desc
,
&
err
,
sizeof
(
err
));
err
=
system
(
START_TERMINAL
);
NSLog
(
@"Terminal returned an error: %d"
,
err
);
if
(
err
)
{
AEDisposeDesc
(
&
desc
);
NSLog
(
@"doscript: system(): %s
\n
"
,
strerror
(
errno
));
}
else
if
(
err
==
errAEDescNotFound
)
{
goto
bail
;
err
=
noErr
;
}
}
else
{
do
{
NSLog
(
@"AEGetPArmDesc returned an error: %d"
,
err
);
sleep
(
1
);
}
/* send the event again */
err
=
AESend
(
&
theAEvent
,
&
theReply
,
kAEWaitReply
,
kAENormalPriority
,
kAEDefaultTimeout
,
NULL
,
NULL
);
}
while
(
err
==
-
600
&&
--
count
>
0
);
if
(
err
==
-
600
)
NSLog
(
@"doscript: Could not activate Terminal
\n
"
);
}
if
(
err
!=
noErr
)
{
NSLog
(
@"doscript: AESend(activate): error %d
\n
"
,
err
);
goto
bail
;
}
/* create the "doscript with command" event for Terminal */
err
=
AECreateAppleEvent
(
DOSCRIPT_SUITE
,
DOSCRIPT_CMD
,
&
terminalAddress
,
kAutoGenerateReturnID
,
kAnyTransactionID
,
&
theAEvent
);
if
(
err
!=
noErr
)
{
NSLog
(
@"doscript: AECreateAppleEvent(doscript): error %d
\n
"
,
err
);
goto
bail
;
}
/* add the command to the apple event */
err
=
AECreateDesc
(
typeChar
,
command
,
strlen
(
command
),
&
commandDesc
);
if
(
err
!=
noErr
)
{
NSLog
(
@"doscript: AECreateDesc(command): error %d
\n
"
,
err
);
goto
bail
;
}
err
=
AEPutParamDesc
(
&
theAEvent
,
WITHCOMMAND
,
&
commandDesc
);
if
(
err
!=
noErr
)
{
NSLog
(
@"doscript: AEPutParamDesc: error %d
\n
"
,
err
);
goto
bail
;
}
/* send the command event to Terminal.app */
return
err
;
err
=
AESend
(
&
theAEvent
,
&
theReply
,
kAEWaitReply
,
kAENormalPriority
,
kAEDefaultTimeout
,
NULL
,
NULL
);
if
(
err
!=
noErr
)
{
NSLog
(
@"doscript: AESend(docommand): error %d
\n
"
,
err
);
goto
bail
;
}
/* clean up and leave */
bail:
AEDisposeDesc
(
&
commandDesc
);
AEDisposeDesc
(
&
theAEvent
);
AEDisposeDesc
(
&
terminalAddress
);
AEDisposeDesc
(
&
theReply
);
return
err
;
}
}
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