Friday, December 15, 2017

#1 2017-11-16 04:02:37 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 643

Script doesnt work as expected after upgrade to high sierra

Hi all

The below code has worked flawlessly for a long time, until I upgraded to OS X 10.13.1.

When an item in a drop box is selected like this text "CSR" the search goes and finds all files that have CSRSTOCK in it  ie: "12345-M110-CSRSTOCK.ps"

After the upgrade nothing shows in the "aPopupMenu", and I see no errors either, which I find strange.

I am still slowly trying to learn about apple script objc, and would appreciate any one offering possible reasons or fixes, as I really dont no where to look to try and sort out what broken.


I hope iv’e explained enough not to make this to confusing, and thanks for any help.



Property

Applescript:

property aPopupMenu : missing value

This builds a list in a drop box

Applescript:

set ClientStockItems to {"Client Stock", "CSR"}
try
ClientStockStyle's removeAllItems()
end try
ClientStockStyle's addItemsWithTitles:ClientStockItems

This adds all items from an external drive to a list that have "CSRSTOCK" in the name i.e. "12345-M110-CSRSTOCK.ps"

Applescript:

on MakeCLientStockChoice_(sender)
set productType to ClientStockStyle's titleOfSelectedItem()
set _OpqType to productType as string
if _OpqType is "CSR" then
makeMenu_("CSRSTOCK", -1)
end if
end MakeCLientStockChoice_

This does all the searching and adds all files that have CSRSTOCK" into a drop box for selection, once the wanted file is selected the file is then sent to an output device. (this part was written by Stefank and has worked flawlessly)

Applescript:

on makeMenu_(searchString)
NSNotificationCenter's defaultCenter's addObserver_selector_name_object_(me, "queryDidFinish:", "NSMetadataQueryDidFinishGatheringNotification", missing value)
set pathExtension to "ps"
set searchPath to "/Volumes/RIP FILES/"
set searchKey to quote & "*" & searchString & "*." & pathExtension & quote
set predicate to NSPredicate's predicateWithFormat_("kMDItemFSName like[c] " & searchKey)
set query to NSMetadataQuery's alloc()'s init()
query's setSearchScopes_({searchPath})
query's setPredicate_(predicate)
query's startQuery()
end makeMenu_

on queryDidFinish_(theNote)
query's stopQuery()
aPopupMenu's removeAllItems()
set foundItems to theNote's |object|()'s results()

-------------------------- THIS MAKES TEXT IN DROP BOX EITHER ASCENDING OR DESCENDING -------------------------------------
set sorter to current application's NSSortDescriptor's sortDescriptorWithKey_ascending_("kMDItemFSName",true) --ASCENDING
--set sorter to current application's NSSortDescriptor's sortDescriptorWithKey_ascending_("kMDItemFSName",false) --DESCENDING
set foundItems to foundItems's sortedArrayUsingDescriptors_({sorter})
---------------------------------------------------------------------------------------------------------------------------
repeat with anItem in foundItems
aPopupMenu's addItemWithTitle_(anItem's valueForAttribute_(current application's NSMetadataItemFSNameKey)'s stringByDeletingPathExtension())
end
NSNotificationCenter's defaultCenter's removeObserver_(me)
end queryDidFinish_

cheers
Budgie


Budgie

"Our greatest glory is not in never falling, but in rising every time we fall"    - Batman

Offline

 

#2 2017-11-16 05:38:59 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Script doesnt work as expected after upgrade to high sierra

One thing that stands out: you passing two arguments to makeMenu_, but it only takes one. Of course, that should never have worked, so perhaps there's something else going on.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2017-11-19 05:10:20 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 643

Re: Script doesnt work as expected after upgrade to high sierra

thanks for your input Shane

I moved the xcode set up to a machine with 10.3.1 on it and recompiled it, and some wierd stuff happened

all the text that I had told to be blue in the coded isn't anymore, its gone back to black, and not sorted in descending format, its not sorted at all.

plus when I click on a button to load text into a drop box "aPopupMenu" I get this error


2017-11-20 11:08:22.241727+1300 FREEZE3[7127:432228] *** -[AppDelegate MostUsed:]: method dictionaryWithObjectsAndKeys: expected 1 arguments, got 5. (error -10000)


Budgie

"Our greatest glory is not in never falling, but in rising every time we fall"    - Batman

Offline

 

#4 2017-11-19 05:18:58 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Script doesnt work as expected after upgrade to high sierra

The dictionaryWithObjectsAndKeys: method doesn't work in 10.13. Instead, use dictionaryWithObjects:forKeys:.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#5 2017-11-19 08:11:36 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 643

Re: Script doesnt work as expected after upgrade to high sierra

thanks for that Shane, changed it, which eliminated the error.

So to get more information, I have now moved the project onto the mac that uses it, and have done a clean and build, now it's throwing this error upon first launch, not sure what it means

2017-11-20 14:06:46.937122+1300 FREEZE3[60614:1463732] MessageTracer: load_domain_whitelist_search_tree:73: Search tree file's format version number (0) is not supported
2017-11-20 14:06:46.937492+1300 FREEZE3[60614:1463732] MessageTracer: Falling back to default whitelist


Budgie

"Our greatest glory is not in never falling, but in rising every time we fall"    - Batman

Offline

 

#6 2017-11-19 08:53:57 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Script doesnt work as expected after upgrade to high sierra

You can probably ignore it.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#7 2017-11-27 09:47:35 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 643

Re: Script doesnt work as expected after upgrade to high sierra

I think after a lot of shagging around the problem seems to be the main drive is formatted to HFS and the external drive is formatted to APFS, once I reformatted the external back to HFS the problem went away.

Also having the main drive and external drive of APFS stopped the script from working as originally posted.

I thought about downgrading the main and exteranl to HFS, which would stop the issue, but all this would do is put a band aid on sorting this issue as time moves on.

Any suggestions for a work around ?, as id like the code to work using APFS on internal and external drives.


cheers


Budgie

"Our greatest glory is not in never falling, but in rising every time we fall"    - Batman

Offline

 

#8 2017-11-27 10:19:09 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Script doesnt work as expected after upgrade to high sierra

Budgie wrote:

I thought about downgrading the main and exteranl to HFS, which would stop the issue, but all this would do is put a band aid on sorting this issue as time moves on.



Or it might provide time for Apple to deal with the APFS issues...


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)