strange resource missing error
strange resource missing error
- Subject: strange resource missing error
- From: Graham Anderson <email@hidden>
- Date: Wed, 26 Jan 2005 13:53:02 -0800
Someone reported a missing resource error in my applescript app
Seems that if my applescript is in the Applications folder, it produces
a 'missing resource error'
I do have a custom icon on the applescript...could that be doing it
message from Colin Holgate
here was a Edit button, but that didn't do me any good. The error code
was -192, which is just missing resource, so not too informative.
I just managed to reproduce the problem. It happens any time you run it
when it's located in the Applications folder.
any help would be appretiated :)
the code:
global gbaseURL
global gfileName
global gRemotePrefFile
global gLocalPrefFile
global gtheVolume
global quotes
global launcherVer
global userEnvironment
global FonovisaDMG_posixPath
------------------------------------------------------------------------
-----
--Fonovisa Installer/Launcher
------------------------------------------------------------------------
------
on run
--is the user's operating system less than OS X
lessThanOSX()
--global defines
myDefines()
-- are we connected to the internet
connected()
(*
Do we need to update..does remote version [version number on the
server = local version in the user's pref file
here's the skeleton:
if remote version != local version
show update dialog
Update Me
download new dmg
write remote version
quit
Skip Update
set current version to 'need to update'
write xml file of user environment variables
launch the movie
else
Version is up to date
write xml file of user environment variables
launch the movie
*)
myScript()
end run
------------------------------------------------------------------------
-----
-- if OS 9 or below
------------------------------------------------------------------------
------
on lessThanOSX()
copy my gestaltVersion_info("sysv", 4) to {system_version,
system_string}
if the system_version is less than "1000" then
-- OS 9: launch movie without creating a preference file or version
checking
launchMovie()
return
else
-- OS X: continue on with script
end if
end lessThanOSX
------------------------------------------------------------------------
-----
-- DEFINES
------------------------------------------------------------------------
------
on myDefines()
set gbaseURL to "http://www.siren.cc/Univision/fonovisa/Library/nsis/"
set gfileName to "!Fonovisa"
set gLocalPrefFile to "!Fonovisa.xml"
set gRemotePrefFile to "macversion.xml"
set gtheVolume to "Fonovisa.dmg"
set quotes to "\""
--POSIX Path to Desktop for the Fonovisa.dmg volume
set my_path to path to desktop
set FonovisaDMG_posixPath to POSIX path of my_path & gtheVolume
return FonovisaDMG_posixPath
end myDefines
------------------------------------------------------------------------
-----
-- Are we connected to the internet
------------------------------------------------------------------------
------
on connected()
set ping to (do shell script "ping -c1 google.com") contains "1
packets received"
delay 0.5
if not ping then
display dialog "You must be connected to the Internet to see the
Fonovisa Player" buttons "quit" giving up after 5 with icon stop
return -- seems to exit the script
else
-- go on with with script
end if
end connected
------------------------------------------------------------------------
---
-- Check for first install..then launch or update
------------------------------------------------------------------------
------
on myScript()
-- get LOCAL version if it exists from the local xml string in the
users prefernce file
try
set theScript to "sed -n
'/<launcherVer>/{s/.*<launcherVer>\\(.*\\)<\\/launcherVer>.*/\\1/p;}'
~/Library/Preferences/!Fonovisa.xml"
set localVer to do shell script theScript
--return localVer
on error err
--must not be the first install or the user has messed with the file
--log ("Cat text file error: " & err)
--file must have been removed or screwed with
set localVer to "need to update"
end try
-- get REMOTE currentversion info...what is the most current version
available
set theURL to gbaseURL & gRemotePrefFile
set the_command to "curl -s '" & theURL & "' | grep currentversion"
set remoteVer to (word 6 of (do shell script the_command)) -- get the
most current version number
--return remoteVer
-- Does the xml pref file exist ?
set mypath to (path to preferences) & gLocalPrefFile
set theFile to mypath as text
tell application "System Events"
if not (exists file theFile) then
set noXML to "true"
else
set noXML to "false"
end if
end tell
(* is this the FIRST INSTALL ?
write the remote version number to the launcherVer variable
build and write the xml list to the pref folder
and launch the movie
*)
-- does the XML file exist in the pref folder
if (noXML is "true") then
--return noXML
set launcherVer to remoteVer
XMLFile()
launchMovie()
return
-- is the remote version the same as the local version
else if (localVer is not remoteVer) then
display dialog ¬
"A newer version of Fonovisa is available" buttons {"update me", "no
thanks"} default button "update me" giving up after 7 with icon stop
-- user chose to update....
if button returned of result is "update me" then
set launcherVer to remoteVer
-- download the dmg file with curl
set the_command to "curl " & gbaseURL & gtheVolume & " -o " & quotes
& FonovisaDMG_posixPath & quotes
do shell script the_command
--build and write the xml list to the pref folder for this dmg to
accesss
XMLFile()
display dialog "downloading Foovisa.dmg
Click on the Fonovisa.dmg file on your desktop to access the new
version " buttons {"quit"} giving up after 3 with icon 1
return
else if button returned of result is "no thanks" then
(* user chose not to update
write the remote version number to the launcherVer variable
so build and write the xml list to the pref folder
and launch the movie
*)
set launcherVer to "need to update"
XMLFile()
launchMovie()
end if
else
(* Everything is current...build pref file and launch the movie
everything is current: localVer = remoteVer
build and write the xml list to the pref folder for this dmg to access
*)
set launcherVer to remoteVer
XMLFile()
launchMovie()
end if
end myScript
------------------------------------------------------------------------
-----
-- get user environment and build the XML list from it
------------------------------------------------------------------------
------
on XMLFile()
------Get user variables to put in xml file
--Admin or Not
set admin to do shell script "whoami | id | grep admin"
if admin ≠ "" then -- not equal to
set accountType to "admin"
else
set accountType to "admin"
end if
--Get IP
set localhostip to ¬
do shell script "ifconfig | grep 'broadcast' | awk '{print $6}'"
--User Name
set user to get system attribute "USER"
--Language
set defaultLanguage to ""
try
set defaultLanguage to system attribute "LANG"
if defaultLanguage = "" then set defaultLanguage to do shell script
"defaults read -g AppleLocale"
end try
if defaultLanguage = "" then set defaultLanguage to "en"
--Computer name
set computername to do shell script "hostname | awk -F. '{print $1}'"
--Quicktime Version
copy my gestaltVersion_info("qtim", 8) to {QT_version, QT_string}
--QSXE Component ..is it installed
set mypath to ":Library:QuickTime:QSXEssentials.component"
set theFile to mypath as text
tell application "System Events"
if not (exists file theFile) then
set qsxe to "no"
--display dialog "Fonovisa needs to install a component into
Quicktime" buttons "Ok" "No" giving up after 5 seconds
else
set qsxe to "yes"
end if
end tell
--ethernet Address... instead of hard drive serial number
set MAC to (words 2 thru -1 of (do shell script "ifconfig en0 | grep
'ether'")) as string
--MHZ
set prcClckMHz to round ((system attribute "pclk") / 1.0E+6)
set busClckMHz to round ((system attribute "bclk") / 1.0E+6)
--RAM
set ram to get system attribute "ram " -- note the space
set ramStr to convertByteSize on ram
--Operating System
tell application "Finder" to set sysVers to system attribute "sysv"
tell application "Finder" to set runningX to ((system attribute
"sysv") ≥ 4096)
if runningX then
set os to "OS X"
else
set os to "OS 9"
end if
-- Build the xml string from the variables above
set userEnvironment to ¬
"<?xml version=\"1.0\" ?>" & "
" & ¬
"<preferences>" & "
" & ¬
"<launcherVer>" & launcherVer & "</launcherVer>" & "
" & ¬
"<computername>" & computername & "</computername>" & "
" & ¬
"<accounttype>" & accountType & "</accounttype>" & "
" & ¬
"<localhostip>" & localhostip & "</localhostip>" & "
" & ¬
"<mac>" & MAC & "</mac>" & "
" & ¬
"<user>" & user & "</user>" & "
" & ¬
"<os>" & os & "</os>" & "
" & ¬
"<cpu>" & prcClckMHz & "</cpu>" & "
" & ¬
"<ram>" & ramStr & "</ram>" & "
" & ¬
"<hdsn>" & "" & "</hdsn>" & "
" & ¬
"<language>" & defaultLanguage & "</language>" & "
" & ¬
"<colorBits>" & "millions" & "</colorBits>" & "
" & ¬
"<quicktime>" & QT_version & "</quicktime>" & "
" & ¬
"<quicktimeinstall>" & "full" & "</quicktimeinstall>" & "
" & ¬
"<qsxe>" & qsxe & "</qsxe>" & "
" & ¬
"</preferences>"
-- Write xml file to user's preference folder
set this_data to userEnvironment
set this_file to (path to preferences as string) & "!Fonovisa.xml"
my write_to_file(this_data, this_file, false)
end XMLFile
--return userEnvironment
------------------------------------------------------------------------
-----
-- Launch Movie
------------------------------------------------------------------------
------
on launchMovie()
--Launch Quicktime Movie
tell application "QuickTime Player"
launch -- bypasses promo movie
set ignore auto play to true
set ignore auto present to true
activate
stop every movie
try
open location gbaseURL & "Launch_Fonovisa.qtl"
on error
display dialog ¬
"Sorry, Fonovisa's network is down or unavailable. Check back again
shortly" buttons "quit" giving up after 5 with icon 0
return
end try
end tell
end launchMovie
------------------------------------------------------------------------
-----
-- Write XML String to the Preference File
------------------------------------------------------------------------
------
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
------------------------------------------------------------------------
-----
-- Convert Byte Size
------------------------------------------------------------------------
------
-- Convert bytes to a readable string in bytes-K-MB-GB as required.
-- Pass the number in bytes. Returns string.
to convertByteSize on theRawSize
set oneK to 2 ^ 10
set oneMB to 2 ^ 20
set oneGB to 2 ^ 30
tell theRawSize to ¬
if it ≥ oneGB then
return ((it div oneGB) & "." & text 2 thru 3 of ((100 + ((it mod
oneGB) div (oneK * 1.0E+4))) as string) & " GB") as string
else if it ≥ oneMB then
return ((it div oneMB) & "." & text 2 thru 3 of ((100 + ((it mod
oneMB) div (oneK * 10))) as string) & " MB") as string
else if it ≥ oneK then
return (it div oneK & " KB") as string
else
return (it & " bytes") as string
end if
end convertByteSize
------------------------------------------------------------------------
-----
-- Gestalt Version
------------------------------------------------------------------------
------
on gestaltVersion_info(gestalt_code, string_length)
try
tell application "Finder" to ¬
copy my NumToHex((system attribute gestalt_code), ¬
string_length) to {a, b, c, d}
set the numeric_version to {a, b, c, d} as string
if a is "0" then set a to ""
set the version_string to (a & b & "." & c & "." & d) as string
return {numeric_version, version_string}
on error
return {"", "unknown"}
end try
end gestaltVersion_info
------------------------------------------------------------------------
-----
-- Num to Hex conversion
------------------------------------------------------------------------
------
on NumToHex(hexData, stringLength)
set hexString to {}
repeat with i from stringLength to 1 by -1
set hexString to ((hexData mod 16) as string) & hexString
set hexData to hexData div 16
end repeat
return (hexString as string)
end NumToHex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden