BOX

[BOX]バージョンチェッカー(v4追加されるJSONのURLを想定してメンテフリーになるようにした)


【スクリプトエディタで開く】 |

バージョンチェッカーJSON.v4.applescript
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004com.cocolog-nifty.quicktimer.icefloe
005v3 Autoupdate5.json 対応
006v4 追加されるJSONURLを想定してメンテフリーになるようにした
007*)
008#
009----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
010use AppleScript version "2.8"
011use framework "Foundation"
012use framework "UniformTypeIdentifiers"
013use framework "AppKit"
014use scripting additions
015property refMe : a reference to current application
016
017###アプリケーションのバンドルID
018set strBundleID to "com.box.desktop"
019
020set strBaseURL to ("https://cdn07.boxcdn.net/Autoupdate") as text
021
022###戻り値格納用のDICT
023set ocidPkgDict to refMe's NSMutableDictionary's alloc()'s init()
024
025##エラーになるまで繰り返す
026repeat with itemNo from 1 to 20 by 1
027   if itemNo = 1 then
028      set strURL to ("" & strBaseURL & ".json") as text
029   else
030      set strItemNo to itemNo as text
031      set strURL to ("" & strBaseURL & strItemNo & ".json") as text
032   end if
033   ###URL
034   #   log strURL
035   set ocidURLString to (refMe's NSString's stringWithString:(strURL))
036   set ocidURL to (refMe's NSURL's alloc()'s initWithString:(ocidURLString))
037   # URLリクエスト
038   set ocidPolicy to (refMe's NSURLRequestReloadIgnoringCacheData)
039   set appRequest to (refMe's NSURLRequest's alloc()'s initWithURL:(ocidURL) cachePolicy:(ocidPolicy) timeoutInterval:5.0)
040   set listResponse to (refMe's NSURLConnection's sendSynchronousRequest:(appRequest) returningResponse:(reference) |error|:(reference))
041   #レスポンスコードを取得して
042   set numResponseCode to (item 2 of listResponse)'s statusCode()
043   #リクエストがエラーコードを返したらリピート終了
044   if numResponseCode > 299 then
045      exit repeat
046   else
047      ###NSDATA読み込み
048      set ocidOption to refMe's NSDataReadingMappedIfSafe
049      set listResponse to (refMe's NSData's dataWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference))
050      set ocidJsonData to (item 1 of listResponse)
051      ###JSON初期化 してレコードに格納
052      set ocidOption to (refMe's NSJSONReadingJSON5Allowed)
053      set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidJsonData) options:(ocidOption) |error|:(reference))
054      set ocidJsonData to (item 1 of listResponse)
055      ##rootのレコード
056      set ocidReadDict to (refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData))
057      set ocidMacDict to (ocidReadDict's objectForKey:("mac"))
058      set ocidEapDict to (ocidMacDict's objectForKey:("eap"))
059      set ocidPkgURL to (ocidEapDict's valueForKey:("download-url")) as text
060      set ocidVersion to (ocidReadDict's valueForKeyPath:("mac.eap.version"))
061      (ocidPkgDict's setValue:(ocidPkgURL) forKey:(ocidVersion))
062   end if
063end repeat
064#ソート 逆順
065set ocidAllKeys to ocidPkgDict's allKeys()
066set ocidAllKeys to (ocidAllKeys's sortedArrayUsingSelector:"localizedStandardCompare:")
067set ocidAllKeysEnu to ocidAllKeys's reverseObjectEnumerator()
068set ocidReversedArray to ocidAllKeysEnu's allObjects()
069
070set listAllKeys to ocidReversedArray as list
071#最初の項目が最新バージョン
072set ocidMacEapVer to ocidReversedArray's firstObject()
073
074################################################
075#テキストデータ生成
076################################################
077set ocidOutStringString to refMe's NSMutableString's alloc()'s init()
078
079repeat with itemKeys in listAllKeys
080   ##
081   set ocidURL to (ocidPkgDict's valueForKey:(itemKeys))
082   (ocidOutStringString's appendString:("Version: "))
083   (ocidOutStringString's appendString:(itemKeys))
084   (ocidOutStringString's appendString:("\n"))
085   (ocidOutStringString's appendString:(ocidURL))
086   (ocidOutStringString's appendString:("\n\n"))
087end repeat
088
089################################################
090###### インストール済みのパージョン
091################################################
092set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
093##バンドルからアプリケーションのURLを取得
094set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
095if ocidAppBundle ≠ (missing value) then
096   set ocidAppPathURL to ocidAppBundle's bundleURL()
097else if ocidAppBundle = (missing value) then
098   set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
099end if
100##予備(アプリケーションのURL
101if ocidAppPathURL = (missing value) then
102   tell application "Finder"
103      try
104         set aliasAppApth to (application file id strBundleID) as alias
105         set strAppPath to POSIX path of aliasAppApth as text
106         set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
107         set strAppPath to strAppPathStr's stringByStandardizingPath()
108         set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
109      on error
110         return "アプリケーションが見つかりませんでした"
111      end try
112   end tell
113end if
114set ocidFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist")
115#####PLISTの内容を読み込んで
116set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
117set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
118set ocidPlistDict to item 1 of listReadPlistData
119set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"
120
121
122################################################
123###### チェック
124################################################
125set strCfbundleversionJson to ocidMacEapVer as text
126set strCfbundleversionPlist to ocidCfbundleversionPlist as text
127#
128if strCfbundleversionJson is strCfbundleversionPlist then
129   set strTitle to ("最新版を利用中です") as text
130   set strCom to ("最新版を利用中です\r" & strCfbundleversionJson & "\rEAPは早期リリースです") as text
131   set strMes to ocidOutStringString as text
132else
133   set strTitle to ("アップデートがあります:" & strCfbundleversionJson) as text
134   set strCom to ("アップデートがあります\r最新:" & strCfbundleversionJson & "\r使用中:" & strCfbundleversionPlist) as text
135   set strMes to ocidOutStringString as text
136end if
137
138################################################
139###### ダイアログ
140################################################
141set appFileManager to refMe's NSFileManager's defaultManager()
142
143####ダイアログに指定アプリのアイコンを表示する
144###アイコン名をPLISTから取得
145set strIconFileName to (ocidPlistDict's valueForKey:("CFBundleIconFile")) as text
146###ICONURLにして
147set strPath to ("Contents/Resources/" & strIconFileName) as text
148set ocidIconFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:(strPath) isDirectory:false
149###拡張子の有無チェック
150set strExtensionName to (ocidIconFilePathURL's pathExtension()) as text
151if strExtensionName is "" then
152   set ocidIconFilePathURL to ocidIconFilePathURL's URLByAppendingPathExtension:"icns"
153end if
154##-->これがアイコンパス
155log ocidIconFilePathURL's absoluteString() as text
156###ICONファイルが実際にあるか?チェック
157set boolExists to appFileManager's fileExistsAtPath:(ocidIconFilePathURL's |path|)
158###ICONがみつかない時用にデフォルトを用意する
159if boolExists is false then
160   set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
161else
162   set aliasIconPath to ocidIconFilePathURL's absoluteURL() as alias
163   set strIconPath to ocidIconFilePathURL's |path|() as text
164end if
165
166set recordResult to (display dialog strCom with title strTitle default answer strMes buttons {"クリップボードにコピー", "終了", "ダウンロード"} default button "ダウンロード" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer)
167
168if button returned of recordResult is "ダウンロード" then
169   tell application "Finder"
170      open location (ocidMacEapURL as text)
171   end tell
172end if
173if button returned of recordResult is "クリップボードにコピー" then
174   try
175      set strText to text returned of recordResult as text
176      ####ペーストボード宣言
177      set appPasteboard to refMe's NSPasteboard's generalPasteboard()
178      set ocidText to (refMe's NSString's stringWithString:(strText))
179      appPasteboard's clearContents()
180      appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
181   on error
182      tell application "Finder"
183         set the clipboard to strTitle as text
184      end tell
185   end try
186end if
AppleScriptで生成しました

| | コメント (0)

[Box Drive]新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。v3(ステータスコードの取得方法を変更した)

新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。 最新バージョンのBox Driveをインストールしてください。問題が解決しない場合、Boxサポートに連絡してトラブルシューティングを行ってください。 新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。
最新バージョンのBox Driveをインストールしてください。問題が解決しない場合、Boxサポートに連絡してトラブルシューティングを行ってください。
Screen-20230721-14602
こちらが発生した場合の最新EAP版のインストールが必要になります
そこで最新のPKGのURLを取得します。

解決方法
『EAP版』Early Access Program(アーリーアクセスプログラム)
早期リリース版をインストールする必要がある

【スクリプトエディタで開く】 |

001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004BOXのアップデート インストーラーのURLを取得する
005v2 追加されるJSONURLを想定してメンテフリーになるようにした
006v3 NSURLConnectionが非推奨になったのでNSURLSessionを利用
007
008*)
009----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
010use AppleScript version "2.8"
011use framework "Foundation"
012use framework "AppKit"
013use scripting additions
014
015property refMe : a reference to current application
016
017set strBaseURL to ("https://cdn07.boxcdn.net/Autoupdate") as text
018
019
020###戻り値格納用のDICT
021set ocidPkgDict to refMe's NSMutableDictionary's alloc()'s init()
022
023##エラーになるまで繰り返す
024repeat with itemNo from 1 to 20 by 1
025   if itemNo = 1 then
026      set strURL to ("" & strBaseURL & ".json") as text
027   else
028      set strItemNo to itemNo as text
029      set strURL to ("" & strBaseURL & strItemNo & ".json") as text
030   end if
031   ###URL
032   #   log strURL
033   set ocidURLString to (refMe's NSString's stringWithString:(strURL))
034   set ocidURL to (refMe's NSURL's alloc()'s initWithString:(ocidURLString))
035   #リクエスト
036   set appRequest to (refMe's NSMutableURLRequest's requestWithURL:(ocidURL))
037   (appRequest's setHTTPMethod:("GET"))
038   (appRequest's setTimeoutInterval:(1))
039   #セッション
040   set ocidConf to refMe's NSURLSessionConfiguration's defaultSessionConfiguration()
041   set appQueue to refMe's NSOperationQueue's mainQueue()
042   set appSession to (refMe's NSURLSession's sessionWithConfiguration:(ocidConf) delegate:("self") delegateQueue:(appQueue))
043   #簡易にこの記述でもいい
044   #set appSession to refMe's NSURLSession's sharedSession()
045   #タスク
046   set appTask to (appSession's dataTaskWithRequest:(appRequest))
047   #タスクスタート
048   appTask's resume()
049   repeat 10 times
050      set ocidStatue to appTask's response()
051      log ocidStatue
052      if ocidStatue = (missing value) then
053         delay 0.2
054      else
055         set ocidStatue to appTask's response()
056         set strStatusCode to ocidStatue's statusCode()
057         exit repeat
058      end if
059   end repeat
060   #タスク終了
061   appTask's cancel()
062   #判定用に整数に
063   set numResponseCode to strStatusCode as integer
064   if numResponseCode > 299 then
065      exit repeat
066   else
067      ###NSDATA読み込み
068      set ocidOption to refMe's NSDataReadingMappedIfSafe
069      set listResponse to (refMe's NSData's dataWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference))
070      set ocidJsonData to (item 1 of listResponse)
071      ###JSON初期化 してレコードに格納
072      set ocidOption to (refMe's NSJSONReadingJSON5Allowed)
073      set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidJsonData) options:(ocidOption) |error|:(reference))
074      set ocidJsonData to (item 1 of listResponse)
075      ##rootのレコード
076      set ocidReadDict to (refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData))
077      set ocidMacDict to (ocidReadDict's objectForKey:("mac"))
078      set ocidEapDict to (ocidMacDict's objectForKey:("eap"))
079      set ocidPkgURL to (ocidEapDict's valueForKey:("download-url")) as text
080      set ocidVersion to (ocidReadDict's valueForKeyPath:("mac.eap.version"))
081      (ocidPkgDict's setValue:(ocidPkgURL) forKey:(ocidVersion))
082   end if
083end repeat
084
085set ocidAllKeys to ocidPkgDict's allKeys()
086set ocidAllKeys to (ocidAllKeys's sortedArrayUsingSelector:"localizedStandardCompare:")
087set listAllKeys to ocidAllKeys as list
088##############################
089###ダイアログを前面に出す
090tell current application
091   set strName to name as text
092end tell
093###スクリプトメニューから実行したら
094if strName is "osascript" then
095   tell application "Finder" to activate
096else
097   tell current application to activate
098end if
099###
100set strTitle to "選んでください" as text
101set strPrompt to "ダウンロードするバージョンを選んでください" as text
102try
103   set listResponse to (choose from list listAllKeys with title strTitle with prompt strPrompt default items (last item of listAllKeys) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed and empty selection allowed) as list
104on error
105   log "エラーしました"
106   return "エラーしました"
107   error "エラーしました" number -200
108end try
109if listResponse = {} then
110   log "何も選択していない"
111   error "何も選択していない"
112else if (item 1 of listResponse) is false then
113   return "キャンセルしました"
114   error "キャンセルしました" number -200
115else
116   set strValue to (ocidPkgDict's valueForKey:(item 1 of listResponse)) as text
117end if
118
119##############################
120set strName to (name of current application) as text
121if strName is "osascript" then
122   tell application "SystemUIServer" to activate
123else
124   tell current application to activate
125end if
126set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
127set strMes to ("パッケージURL eap 戻り値です\rURL\r" & strValue & "\r\r OKSafariでダウンロードします") as text
128tell application "SystemUIServer"
129   activate
130   set recordResult to (display dialog strMes with title "URL" default answer strValue buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 20 with icon aliasIconPath without hidden answer)
131end tell
132if button returned of recordResult is "クリップボードにコピー" then
133   try
134      set strText to text returned of recordResult as text
135      ####ペーストボード宣言
136      set appPasteboard to refMe's NSPasteboard's generalPasteboard()
137      set ocidText to (refMe's NSString's stringWithString:(strText))
138      appPasteboard's clearContents()
139      appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
140   on error
141      tell application "SystemUIServer" to quit
142      tell application "Finder"
143         set the clipboard to strTitle as text
144      end tell
145   end try
146end if
147tell application "SystemUIServer" to quit
148###OKだったらサファリでダウンロード
149if button returned of recordResult is "OK" then
150   tell application "Safari"
151      open location strValue
152   end tell
153end if

| | コメント (0)

BOXサービスアップデートCanvases

Box,Drive v2.42.212から
Canvases機能が使いやすくなった。
BOXのCanvasesはいわゆるXDのようにも使える
素材・グラフィック・コメントを1元管理できるので
進捗状況を共有するに『好むADさん』がいる
あわせて
モバイルコンフィグのお気に入りManagedBookmarksに入れた

サンプルコード

サンプルソース(参考)
行番号ソース
001<dict>
002<key>name</key>
003<string>Canvas</string>
004<key>url</key>
005<string>https://app.box.com/canvas</string>
006</dict>
007<dict>
008<key>name</key>
009<string>Notes</string>
010<key>url</key>
011<string>https://app.box.com/notes</string>
012</dict>
013<dict>
014<key>name</key>
015<string>Sign</string>
016<key>url</key>
017<string>https://app.box.com/sign</string>
018</dict>
AppleScriptで生成しました

ついでに
Apple関連のURLも ManagedBookmarksに追加した

サンプルコード

サンプルソース(参考)
行番号ソース
001<dict>
002<key>name</key>
003<string>Status</string>
004<key>url</key>
005<string>https://www.apple.com/support/systemstatus/</string>
006</dict>
007<dict>
008<key>name</key>
009<string>FeedbackAssistant</string>
010<key>url</key>
011<string>https://feedbackassistant.apple.com/</string>
012</dict>
013<dict>
014<key>name</key>
015<string>Dev</string>
016<key>url</key>
017<string>https://developer.apple.com/download/all/</string>
018</dict>
AppleScriptで生成しました

|

[BOX]BOXで共有したPDFに注釈作業を共同で行う

BOX(クラウドストレージ)で共有したPDFに
documentcloud.adobe.comのintegrationモードで共有して
コメントの入力作業を共同で行う

前提条件 
1:全員にBOXアカウントがある事 個人アカウントは無料
2:全員にAdobeIDがある事
(両方とも無料のアカウントでOK)

事前準備
1:BOXにログイン
2:統合アプリAdobe Acrobat for Boxを適応
3:PDFのデフォルトをAcrobatに変更
4:Acrobat.comにAdobeIDでログインしておく

処理(共有側 PDFの所有者側)
1:共有用にフォルダを作成する
2:共有用のフォルダに共同作業者(コラボレーター)を編集権限で追加
3:共有用して注釈処理をしたいPDFを対象のフォルダにアップロード
4:アップロードしたPDFを編集権限で共有




前提条件 
1:全員にBOXアカウントがある事
個人アカウントは無料

2:全員にAdobeIDがある事
個人アカウントの無料版でもOK
202411210136401_1022x760



事前準備(対象者全員)
1:BOXにログイン
BOXのアカウント(無料版でOK)を利用して
BOXにログインしておく

2:統合アプリAdobe Acrobat for Boxを適応
Adobe Acrobat for Box
BOXのPDFをAcrobat.comに渡して処理するためのAPP
202411210138331_1196x720

202411210142221_1816x766

3:PDFのデフォルトをAcrobatに変更
BOXのアカウント設定でPDFをAdobe Acrobatに変更しておく
202411210144101_1812x614

4:Acrobat.comにAdobeIDでログインしておく
acrobat.adobe.comへの
ログインを済ませておいた方が後でトラブルが出にくいです
202411210146181_1384x258



処理(共有側 PDFの所有者側)

1:共有用にフォルダを作成する
202411210148491_716x398

2:共有用のフォルダに共同作業者(コラボレーター)を編集権限で追加
202411210149311_932x844

3:共有用して注釈処理をしたいPDFを対象のフォルダにアップロード
202411210151281_1880x5282

4:アップロードしたPDFを編集権限で共有
202411210151281_1880x528_20241121015301

どの方法にするにしても
『編集者権限』でコラボレーターとして招待する必要があります
202411210155461_1748x1302



あとは Adobe Acrobatで開くを実行すれば
202411210158451_2326x452

202411210158561_1432x9402

BOXのクラウドストレージにあるPDFを
Acrobat.comの機能を使って注釈入れたりできます
202411210159211_2302x772

|

[BOX]バージョンチェッカーJSONv3 (Autoupdate5.json)


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004com.cocolog-nifty.quicktimer.icefloe
005Autoupdate5.json 対応
006
007*)
008#
009----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
010use AppleScript version "2.8"
011use framework "Foundation"
012use framework "UniformTypeIdentifiers"
013use framework "AppKit"
014use scripting additions
015property refMe : a reference to current application
016
017###アプリケーションのバンドルID
018set strBundleID to "com.box.desktop"
019
020set strURL to "https://cdn07.boxcdn.net/Autoupdate5.json" as text
021
022set coidURLStr to refMe's NSString's stringWithString:(strURL)
023set ocidURL to refMe's NSURL's URLWithString:(coidURLStr)
024
025################################################
026###### URLRequest部分
027################################################
028set ocidURLRequest to refMe's NSMutableURLRequest's alloc()'s init()
029ocidURLRequest's setHTTPMethod:"GET"
030ocidURLRequest's setURL:(ocidURL)
031ocidURLRequest's addValue:"application/json" forHTTPHeaderField:"Content-Type"
032###ポストするデータは空
033ocidURLRequest's setHTTPBody:(missing value)
034
035################################################
036###### データ取得
037################################################
038set ocidServerResponse to refMe's NSURLConnection's sendSynchronousRequest:(ocidURLRequest) returningResponse:(missing value) |error| :(reference)
039###取得
040set coidReadData to (item 1 of ocidServerResponse)
041##NSJSONSerialization's
042set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(coidReadData) options:(refMe's NSJSONReadingMutableContainers) |error| :(reference))
043set ocidJsonData to item 1 of listJSONSerialization
044##NSDictionary's
045set ocidJsonDict to refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData)
046#
047set ocidOutStringString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
048
049################################################
050###### データ精査
051################################################
052set ocidMacDict to (ocidJsonDict's objectForKey:("mac"))
053set ocidMacEapDict to ocidMacDict's objectForKey:("eap")
054set ocidMacEapVer to (ocidMacEapDict's valueForKey:("version"))
055set ocidMacEapURL to (ocidMacEapDict's valueForKey:("download-url"))
056#
057set ocidAllKeys to ocidMacDict's allKeys()
058#
059repeat with itemKey in ocidAllKeys
060  set ocidSubDict to (ocidMacDict's objectForKey:(itemKey))
061  set ocidMacVer to (ocidSubDict's valueForKey:("version"))
062  set ocidMacURL to (ocidSubDict's valueForKey:("download-url"))
063  (ocidOutStringString's appendString:(itemKey))
064  (ocidOutStringString's appendString:("\n"))
065  (ocidOutStringString's appendString:(ocidMacVer))
066  (ocidOutStringString's appendString:("\n"))
067  (ocidOutStringString's appendString:(ocidMacURL))
068  (ocidOutStringString's appendString:("\n"))
069end repeat
070
071
072################################################
073###### データ精査
074################################################
075set ocidMacMinDict to (ocidJsonDict's objectForKey:("mac_min"))
076##
077set ocidMacMinVer to (ocidMacMinDict's valueForKey:("version"))
078set ocidMacMinURL to (ocidMacMinDict's valueForKey:("download-url"))
079(ocidOutStringString's appendString:("mac_min"))
080(ocidOutStringString's appendString:("\n"))
081(ocidOutStringString's appendString:(ocidMacMinVer))
082(ocidOutStringString's appendString:("\n"))
083(ocidOutStringString's appendString:(ocidMacMinURL))
084(ocidOutStringString's appendString:("\n"))
085
086
087set strURL to "https://cdn07.boxcdn.net/Autoupdate4.json" as text
088
089set coidURLStr to refMe's NSString's stringWithString:(strURL)
090set ocidURL to refMe's NSURL's URLWithString:(coidURLStr)
091
092################################################
093###### URLRequest部分
094################################################
095set ocidURLRequest to refMe's NSMutableURLRequest's alloc()'s init()
096ocidURLRequest's setHTTPMethod:"GET"
097ocidURLRequest's setURL:(ocidURL)
098ocidURLRequest's addValue:"application/json" forHTTPHeaderField:"Content-Type"
099###ポストするデータは空
100ocidURLRequest's setHTTPBody:(missing value)
101
102################################################
103###### データ取得
104################################################
105set ocidServerResponse to refMe's NSURLConnection's sendSynchronousRequest:(ocidURLRequest) returningResponse:(missing value) |error| :(reference)
106###取得
107set coidReadData to (item 1 of ocidServerResponse)
108##NSJSONSerialization's
109set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(coidReadData) options:(refMe's NSJSONReadingMutableContainers) |error| :(reference))
110set ocidJsonData to item 1 of listJSONSerialization
111##NSDictionary's
112set ocidJsonDict to refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData)
113
114################################################
115###### データ精査
116################################################
117set ocidMacDict to (ocidJsonDict's objectForKey:("mac"))
118#
119set ocidAllKeys to ocidMacDict's allKeys()
120#
121repeat with itemKey in ocidAllKeys
122  set ocidSubDict to (ocidMacDict's objectForKey:(itemKey))
123  set ocidMacVer to (ocidSubDict's valueForKey:("version"))
124  set ocidMacURL to (ocidSubDict's valueForKey:("download-url"))
125  (ocidOutStringString's appendString:(itemKey))
126  (ocidOutStringString's appendString:("\n"))
127  (ocidOutStringString's appendString:(ocidMacVer))
128  (ocidOutStringString's appendString:("\n"))
129  (ocidOutStringString's appendString:(ocidMacURL))
130  (ocidOutStringString's appendString:("\n"))
131end repeat
132
133
134################################################
135###### データ精査
136################################################
137set ocidMacMinDict to (ocidJsonDict's objectForKey:("mac_min"))
138##
139set ocidMacMinVer to (ocidMacMinDict's valueForKey:("version"))
140set ocidMacMinURL to (ocidMacMinDict's valueForKey:("download-url"))
141(ocidOutStringString's appendString:("mac_min"))
142(ocidOutStringString's appendString:("\n"))
143(ocidOutStringString's appendString:(ocidMacMinVer))
144(ocidOutStringString's appendString:("\n"))
145(ocidOutStringString's appendString:(ocidMacMinURL))
146(ocidOutStringString's appendString:("\n"))
147
148
149################################################
150###### インストール済みのパージョン
151################################################
152set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
153##バンドルからアプリケーションのURLを取得
154set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
155if ocidAppBundle ≠ (missing value) then
156  set ocidAppPathURL to ocidAppBundle's bundleURL()
157else if ocidAppBundle = (missing value) then
158  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
159end if
160##予備(アプリケーションのURL)
161if ocidAppPathURL = (missing value) then
162  tell application "Finder"
163    try
164      set aliasAppApth to (application file id strBundleID) as alias
165      set strAppPath to POSIX path of aliasAppApth as text
166      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
167      set strAppPath to strAppPathStr's stringByStandardizingPath()
168      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
169    on error
170      return "アプリケーションが見つかりませんでした"
171    end try
172  end tell
173end if
174set ocidFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist")
175#####PLISTの内容を読み込んで
176set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
177set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL  |error| :(reference)
178set ocidPlistDict to item 1 of listReadPlistData
179set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"
180
181
182################################################
183###### チェック
184################################################
185set strCfbundleversionJson to ocidMacEapVer as text
186set strCfbundleversionPlist to ocidCfbundleversionPlist as text
187#
188if strCfbundleversionJson is strCfbundleversionPlist then
189  set strTitle to ("最新版を利用中です") as text
190  set strCom to ("最新版を利用中です\r" & strCfbundleversionJson & "\rEAPは早期リリースです") as text
191  set strMes to ocidOutStringString as text
192else
193  set strTitle to ("アップデートがあります:" & strCfbundleversionJson) as text
194  set strCom to ("アップデートがあります\r最新:" & strCfbundleversionJson & "\r使用中:" & strCfbundleversionPlist) as text
195  set strMes to ocidOutStringString as text
196end if
197
198################################################
199###### ダイアログ
200################################################
201set appFileManager to refMe's NSFileManager's defaultManager()
202
203####ダイアログに指定アプリのアイコンを表示する
204###アイコン名をPLISTから取得
205set strIconFileName to (ocidPlistDict's valueForKey:("CFBundleIconFile")) as text
206###ICONのURLにして
207set strPath to ("Contents/Resources/" & strIconFileName) as text
208set ocidIconFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:(strPath) isDirectory:false
209###拡張子の有無チェック
210set strExtensionName to (ocidIconFilePathURL's pathExtension()) as text
211if strExtensionName is "" then
212  set ocidIconFilePathURL to ocidIconFilePathURL's URLByAppendingPathExtension:"icns"
213end if
214##-->これがアイコンパス
215log ocidIconFilePathURL's absoluteString() as text
216###ICONファイルが実際にあるか?チェック
217set boolExists to appFileManager's fileExistsAtPath:(ocidIconFilePathURL's |path|)
218###ICONがみつかない時用にデフォルトを用意する
219if boolExists is false then
220  set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
221else
222  set aliasIconPath to ocidIconFilePathURL's absoluteURL() as alias
223  set strIconPath to ocidIconFilePathURL's |path|() as text
224end if
225
226set recordResult to (display dialog strCom with title strTitle default answer strMes buttons {"クリップボードにコピー", "終了", "ダウンロード"} default button "ダウンロード" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer)
227
228if button returned of recordResult is "ダウンロード" then
229  tell application "Finder"
230    open location (ocidMacEapURL as text)
231  end tell
232end if
233if button returned of recordResult is "クリップボードにコピー" then
234  try
235    set strText to text returned of recordResult as text
236    ####ペーストボード宣言
237    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
238    set ocidText to (refMe's NSString's stringWithString:(strText))
239    appPasteboard's clearContents()
240    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
241  on error
242    tell application "Finder"
243      set the clipboard to strTitle as text
244    end tell
245  end try
246end if
AppleScriptで生成しました

|

[BOX]バージョンチェッカーJSONv2


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

###アプリケーションのバンドルID
set strBundleID to "com.box.desktop"

set strURL to "https://cdn07.boxcdn.net/Autoupdate4.json" as text

set coidURLStr to refMe's NSString's stringWithString:(strURL)
set ocidURL to refMe's NSURL's URLWithString:(coidURLStr)

################################################
###### URLRequest部分
################################################
set ocidURLRequest to refMe's NSMutableURLRequest's alloc()'s init()
ocidURLRequest's setHTTPMethod:"GET"
ocidURLRequest's setURL:(ocidURL)
ocidURLRequest's addValue:"application/json" forHTTPHeaderField:"Content-Type"
###ポストするデータは空
ocidURLRequest's setHTTPBody:(missing value)

################################################
###### データ取得
################################################
set ocidServerResponse to refMe's NSURLConnection's sendSynchronousRequest:(ocidURLRequest) returningResponse:(missing value) |error|:(reference)
###取得
set coidReadData to (item 1 of ocidServerResponse)
##NSJSONSerialization's
set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(coidReadData) options:(refMe's NSJSONReadingMutableContainers) |error|:(reference))
set ocidJsonData to item 1 of listJSONSerialization
##NSDictionary's
set ocidJsonDict to refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData)
################################################
###### データ精査
################################################
set ocidMacMinDict to (ocidJsonDict's objectForKey:("mac_min"))
##
set ocidMacMinVer to (ocidMacMinDict's valueForKey:("version"))
set ocidMacMinURL to (ocidMacMinDict's valueForKey:("download-url"))
##
set ocidMacDict to (ocidJsonDict's objectForKey:("mac"))
set ocidEapDict to ocidMacDict's objectForKey:("eap")
set ocidEapVer to (ocidEapDict's valueForKey:("version"))
set ocidEapURL to (ocidEapDict's valueForKey:("download-url"))



################################################
###### インストール済みのパージョン
################################################
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
##バンドルからアプリケーションのURLを取得
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
##予備(アプリケーションのURL)
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
      set strAppPath to POSIX path of aliasAppApth as text
      set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
      set strAppPath to strAppPathStr's stringByStandardizingPath()
      set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(strAppPath) isDirectory:true
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
end if
set ocidFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist")
#####PLISTの内容を読み込んで
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listReadPlistData to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference)
set ocidPlistDict to item 1 of listReadPlistData
set ocidCfbundleversionPlist to ocidPlistDict's valueForKey:"CFBundleVersion"


################################################
###### チェック
################################################
set strCfbundleversionJson to ocidMacMinVer as text
set strCfbundleversionPlist to ocidCfbundleversionPlist as text
log strCfbundleversionJson
log strCfbundleversionPlist

if strCfbundleversionJson is strCfbundleversionPlist then
  set strTitle to ("最新版を利用中です") as text
  set strCom to ("最新版を利用中です\r" & strCfbundleversionJson & "\rEAPは早期リリースです") as text
  set strMes to (strTitle & "\rMIN:" & strCfbundleversionJson & "\rEAP:" & (ocidEapVer as text) & "\rPLIST:" & strCfbundleversionPlist & "\rLink:" & (ocidMacMinURL as text) & "\rEAP:" & (ocidEapURL as text)) as text
else
  set strTitle to ("アップデートがあります:" & strCfbundleversionJson) as text
  set strCom to ("アップデートがあります\r最新:" & strCfbundleversionJson & "\r使用中:" & strCfbundleversionPlist) as text
  set strMes to ("最新版ダウンロード:" & (ocidMacMinURL as text) & "\rEAP:" & (ocidEapURL as text)) as text
end if

################################################
###### ダイアログ
################################################
set appFileManager to refMe's NSFileManager's defaultManager()

####ダイアログに指定アプリのアイコンを表示する
###アイコン名をPLISTから取得
set strIconFileName to (ocidPlistDict's valueForKey:("CFBundleIconFile")) as text
###ICONのURLにして
set strPath to ("Contents/Resources/" & strIconFileName) as text
set ocidIconFilePathURL to ocidAppPathURL's URLByAppendingPathComponent:(strPath) isDirectory:false
###拡張子の有無チェック
set strExtensionName to (ocidIconFilePathURL's pathExtension()) as text
if strExtensionName is "" then
  set ocidIconFilePathURL to ocidIconFilePathURL's URLByAppendingPathExtension:"icns"
end if
##-->これがアイコンパス
log ocidIconFilePathURL's absoluteString() as text
###ICONファイルが実際にあるか?チェック
set boolExists to appFileManager's fileExistsAtPath:(ocidIconFilePathURL's |path|)
###ICONがみつかない時用にデフォルトを用意する
if boolExists is false then
  set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
else
  set aliasIconPath to ocidIconFilePathURL's absoluteURL() as alias
  set strIconPath to ocidIconFilePathURL's |path|() as text
end if

set recordResult to (display dialog strCom with title strTitle default answer strMes buttons {"クリップボードにコピー", "終了", "ダウンロード"} default button "ダウンロード" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer)

if button returned of recordResult is "ダウンロード" then
  tell application "Finder"
    open location (ocidMacMinURL as text)
  end tell
end if
if button returned of recordResult is "クリップボードにコピー" then
  try
    set strText to text returned of recordResult as text
    ####ペーストボード宣言
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
  on error
    tell application "Finder"
      set the clipboard to strTitle as text
    end tell
  end try
end if


|

[Bash]新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。

Screen-20230721-14602
EAPアクセス用のPKGをダウンロードしてインストールする事でエラーを解決します

【スクリプトエディタで開く】|

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
########################################
###管理者インストールしているか?チェック
USER_WHOAMI=$(/usr/bin/whoami)
/bin/echo "実行したユーザーは:$USER_WHOAMI"
if [ "$USER_WHOAMI" != "root" ]; then
  /bin/echo "このスクリプトを実行するには管理者権限が必要です。"
  /bin/echo "sudo で実行してください"
  ### path to me
  SCRIPT_PATH="${BASH_SOURCE[0]}"
  /bin/echo "/usr/bin/sudo \"$SCRIPT_PATH\""
  /bin/echo "↑を実行してください"
  exit 1
else
  ###実行しているユーザー名
  SUDO_USER=$(/bin/echo "$HOME" | /usr/bin/awk -F'/' '{print $NF}')
  /bin/echo "実行ユーザー:" "$SUDO_USER"
fi

##########################################
##JSON ダウンロード
STR_JSON_FILE_NAME="Autoupdate3.json"
STR_JSON_URL="https://cdn07.boxcdn.net/Autoupdate3.json"
##起動時に削除される項目
LOCAL_TMP_DIR=$(/usr/bin/sudo -u "$SUDO_USER" /usr/bin/mktemp -d)
/bin/echo "TMPDIR:" "$LOCAL_TMP_DIR"
##ダウンロード
  if ! /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$STR_JSON_FILE_NAME" "$STR_JSON_URL" --connect-timeout 20; then
    /bin/echo "ファイルのダウンロードに失敗しました HTTP1.1で再トライします"
    if ! /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$STR_JSON_FILE_NAME" "$STR_JSON_URL" --http1.1 --connect-timeout 20; then
      /bin/echo "ファイルのダウンロードに失敗しました"
      exit 1
    fi
  fi
/bin/echo "JSONダウンロードOK"
/bin/sleep 1
##########################################
##PLISTに変換
STR_PLIST_FILE_NAME="Autoupdate3.plist"
/usr/bin/plutil -convert xml1 "$LOCAL_TMP_DIR/$STR_JSON_FILE_NAME" -o "$LOCAL_TMP_DIR/$STR_PLIST_FILE_NAME"
/bin/echo "PLIST変換OK"
/bin/sleep 1
##########################################
## ダウンロードURLとバージョン(今回はバージョンチェックはせずEAPアーリーアクセスを利用する)
STR_PKG_URL_EAP=$(/usr/libexec/PlistBuddy -c "Print:mac:eap:download-url" "$LOCAL_TMP_DIR/$STR_PLIST_FILE_NAME")
/bin/echo "EAP:" "$STR_PKG_URL_EAP"
STR_PKG_VER_EAP=$(/usr/libexec/PlistBuddy -c "Print:mac:eap:version" "$LOCAL_TMP_DIR/$STR_PLIST_FILE_NAME")
/bin/echo "EAPv:" "$STR_PKG_VER_EAP"
STR_PKG_URL_RO=$(/usr/libexec/PlistBuddy -c "Print:mac:free:rollout-url" "$LOCAL_TMP_DIR/$STR_PLIST_FILE_NAME")
/bin/echo "Rollout:" "$STR_PKG_URL_RO"
STR_PKG_VER_RO=$(/usr/libexec/PlistBuddy -c "Print:mac:free:rollout-version" "$LOCAL_TMP_DIR/$STR_PLIST_FILE_NAME")
/bin/echo "Rolloutv:" "$STR_PKG_VER_RO"

#################################
###CPUタイプでの分岐
ARCHITEC=$(/usr/bin/arch)
if [ "$ARCHITEC" == "arm64" ]; then
  PKG_FILE_NAME="BoxDrive.pkg"
  STR_URL=$STR_PKG_URL_EAP
else
  PKG_FILE_NAME="BoxDrive.pkg"
  STR_URL=$STR_PKG_URL_EAP
fi
/bin/echo "$STR_URL"
#################################
##ダウンロード
LOCAL_TMP_DIR=$(/usr/bin/sudo -u "$SUDO_USER" /usr/bin/mktemp -d)
/bin/echo "TMPDIR:" "$LOCAL_TMP_DIR"

if [ "$ARCHITEC" == "arm64" ]; then
  /bin/echo "Running on $ARCHITEC"
  ###ダウンロード
  if ! /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --connect-timeout 20; then
    /bin/echo "ファイルのダウンロードに失敗しました HTTP1.1で再トライします"
    if ! /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20; then
      /bin/echo "ファイルのダウンロードに失敗しました"
      exit 1
    fi
  fi
else
  /bin/echo "Running on $ARCHITEC"
  ###ダウンロード
  if ! /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --connect-timeout 20; then
    /bin/echo "ファイルのダウンロードに失敗しました HTTP1.1で再トライします"
    if ! /usr/bin/curl -L -o "$LOCAL_TMP_DIR/$PKG_FILE_NAME" "$STR_URL" --http1.1 --connect-timeout 20; then
      /bin/echo "ファイルのダウンロードに失敗しました"
      exit 1
    fi
  fi
fi
#################################
###プロセス終了
STR_APP_NAME="Box.app"
###
STR_PLIST_PATH="/Applications/$STR_APP_NAME/Contents/Info.plist"
STR_BUNDLE_ID=$(/usr/bin/defaults read "$STR_PLIST_PATH" CFBundleIdentifier)
/bin/echo "STR_BUNDLE_ID" "$STR_BUNDLE_ID"
##念の為 KILLもする
/usr/bin/sudo /usr/bin/killall "Box" 2>/dev/null
/usr/bin/sudo /usr/bin/killall "Box Autoupdater" 2>/dev/null
/usr/bin/sudo /usr/bin/killall "Box Edit" 2>/dev/null
/usr/bin/sudo /usr/bin/killall "Box Edit Finder Extension" 2>/dev/null
/usr/bin/sudo /usr/bin/killall "Box Helper" 2>/dev/null
/usr/bin/sudo /usr/bin/killall "Box Local Com Server" 2>/dev/null
/usr/bin/sudo /usr/bin/killall "Box UI" 2>/dev/null
/usr/bin/sudo /bin/echo "アプリケーション終了"
/bin/sleep 2

#################################
### インストール(上書き)を実行する
/usr/bin/sudo /usr/sbin/installer -pkg "$LOCAL_TMP_DIR/$PKG_FILE_NAME" -target / -dumplog -allowUntrusted -lang ja

/bin/echo "処理終了"
exit 0


|

[BOX]便利ツール v2 20230721

ダウンロード - boxtools.zip

|

[BOX]EAPアーリアクセスプロダクトアップデート

新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。 Screen-20230721-14602
個人用のBOXはアップデートcom.box.desktop.autoupdaterがアーリーアクセスをアップデートした場合
上書きでサイトからダウンロードしたPKGをインストールするとバージョンの違いが発生して起こる
そのため、EAPのパッケージを再インストールする必要が出てくる。

【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#要管理者権限
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

set strURL to "https://cdn07.boxcdn.net/Autoupdate3.json" as text

set listUTI to {"com.box.desktop", "com.box.desktop.ui", "com.box.desktop.autoupdater", "com.box.desktop.helper", "com.box.Box-Device-Trust", "com.Box.BoxToolsCustomApps", "com.box.Box-Local-Com-Server", "com.Box.Box-Edit"} as list

####先に管理者モードにしておく
set strCommandText to ("/usr/bin/sudo /bin/echo \"処理開始\"") as text
###
do shell script strCommandText with administrator privileges
###戻り値格納用のDICT
set ocidPkgDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
###URL
set ocidURLString to (refMe's NSString's stringWithString:(strURL))
set ocidJsonURL to (refMe's NSURL's alloc()'s initWithString:(ocidURLString))
###JSON読み込み
set ocidOption to refMe's NSDataReadingMappedIfSafe
set listReadData to (refMe's NSData's dataWithContentsOfURL:(ocidJsonURL) options:(ocidOption) |error|:(reference))
set ocidJsonData to (item 1 of listReadData)
###JSON初期化 してレコードに格納
set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidJsonData) options:0 |error|:(reference))
set ocidJsonData to item 1 of listJSONSerialization
##rootのレコード
set ocidReadDict to (refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData))
set ocidMacDict to (ocidReadDict's objectForKey:("mac"))
set ocidEapDict to (ocidMacDict's objectForKey:("eap"))
set ocidPkgURL to (ocidEapDict's valueForKey:("download-url"))
set ocidVersion to (ocidReadDict's valueForKeyPath:("mac.eap.version"))
log ocidVersion as text
log ocidPkgURL as text
(ocidPkgDict's setValue:(ocidPkgURL) forKey:(ocidVersion))
###ダウンロード
set ocidURL to refMe's NSURL's URLWithString:(ocidPkgURL)
###ファイル名
set ocidFileName to ocidURL's lastPathComponent()
####NSDataで
set ocidPkgData to refMe's NSData's dataWithContentsOfURL:(ocidURL)
###保存先 ディレクトリ 起動時の削除される項目
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTempDirURL to appFileManager's temporaryDirectory()
set ocidUUID to refMe's NSUUID's alloc()'s init()
set ocidUUIDString to ocidUUID's UUIDString
set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:true
###フォルダ作って
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###保存パス
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidFileName) isDirectory:false
###保存
set boolDone to ocidPkgData's writeToURL:(ocidSaveFilePathURL) atomically:(true)
###インストール用のパス
set strSaveFilePath to ocidSaveFilePathURL's |path|() as text
###関連プロセス終了
repeat with itemUTI in listUTI
  ###NSRunningApplication
  set ocidRunningApplication to refMe's NSRunningApplication
  ###起動中のすべてのリスト
  set ocidAppArray to (ocidRunningApplication's runningApplicationsWithBundleIdentifier:(itemUTI))
  ###複数起動時も順番に終了
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate()
  end repeat
end repeat
###通知のタイムラグを考慮して1秒まってから
delay 1
###コマンド整形
set strCommandText to ("/usr/bin/sudo /usr/sbin/installer -dumplog -verbose -pkg \"" & strSaveFilePath & "\" -target / -allowUntrusted -lang ja") as text
###実行
do shell script strCommandText with administrator privileges
###
return "処理終了"

|

[Box Drive]新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。

アップデートがあります
[Box Drive]新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。v3(ステータスコードの取得方法を変更した)


新しいバージョンのBox Driveに、古いバージョンが上書きインストールされました。
最新バージョンのBox Driveをインストールしてください。問題が解決しない場合、Boxサポートに連絡してトラブルシューティングを行ってください。
Screen-20230721-14602
こちらが発生した場合の最新EAP版のインストールが必要になります
そこで最新のPKGのURLを取得します。

【スクリプトエディタで開く】 |

001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004BOXのアップデート インストーラーのURLを取得する
005v2 追加されるJSONURLを想定してメンテフリーになるようにした
006
007
008*)
009----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
010use AppleScript version "2.8"
011use framework "Foundation"
012use framework "AppKit"
013use scripting additions
014
015property refMe : a reference to current application
016
017set strBaseURL to ("https://cdn07.boxcdn.net/Autoupdate") as text
018
019
020###戻り値格納用のDICT
021set ocidPkgDict to refMe's NSMutableDictionary's alloc()'s init()
022
023##エラーになるまで繰り返す
024repeat with itemNo from 1 to 20 by 1
025   if itemNo = 1 then
026      set strURL to ("" & strBaseURL & ".json") as text
027   else
028      set strItemNo to itemNo as text
029      set strURL to ("" & strBaseURL & strItemNo & ".json") as text
030   end if
031   ###URL
032   log strURL
033   set ocidURLString to (refMe's NSString's stringWithString:(strURL))
034   set ocidURL to (refMe's NSURL's alloc()'s initWithString:(ocidURLString))
035   #
036   set ocidPolicy to (refMe's NSURLRequestReloadIgnoringCacheData)
037   set appRequest to (refMe's NSURLRequest's alloc()'s initWithURL:(ocidURL) cachePolicy:(ocidPolicy) timeoutInterval:5.0)
038   set listResponse to (refMe's NSURLConnection's sendSynchronousRequest:(appRequest) returningResponse:(reference) |error|:(reference))
039   set numResponseCode to (item 2 of listResponse)'s statusCode()
040   if numResponseCode > 299 then
041      exit repeat
042   else
043      ###NSDATA読み込み
044      set ocidOption to refMe's NSDataReadingMappedIfSafe
045      set listResponse to (refMe's NSData's dataWithContentsOfURL:(ocidURL) options:(ocidOption) |error|:(reference))
046      set ocidJsonData to (item 1 of listResponse)
047      ###JSON初期化 してレコードに格納
048      set ocidOption to (refMe's NSJSONReadingJSON5Allowed)
049      set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidJsonData) options:(ocidOption) |error|:(reference))
050      set ocidJsonData to (item 1 of listResponse)
051      ##rootのレコード
052      set ocidReadDict to (refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData))
053      set ocidMacDict to (ocidReadDict's objectForKey:("mac"))
054      set ocidEapDict to (ocidMacDict's objectForKey:("eap"))
055      set ocidPkgURL to (ocidEapDict's valueForKey:("download-url")) as text
056      set ocidVersion to (ocidReadDict's valueForKeyPath:("mac.eap.version"))
057      (ocidPkgDict's setValue:(ocidPkgURL) forKey:(ocidVersion))
058   end if
059end repeat
060
061set ocidAllKeys to ocidPkgDict's allKeys()
062set ocidAllKeys to (ocidAllKeys's sortedArrayUsingSelector:"localizedStandardCompare:")
063set listAllKeys to ocidAllKeys as list
064##############################
065###ダイアログを前面に出す
066tell current application
067   set strName to name as text
068end tell
069###スクリプトメニューから実行したら
070if strName is "osascript" then
071   tell application "Finder" to activate
072else
073   tell current application to activate
074end if
075###
076set strTitle to "選んでください" as text
077set strPrompt to "ダウンロードするバージョンを選んでください" as text
078try
079   set listResponse to (choose from list listAllKeys with title strTitle with prompt strPrompt default items (last item of listAllKeys) OK button name "OK" cancel button name "キャンセル" with multiple selections allowed and empty selection allowed) as list
080on error
081   log "エラーしました"
082   return "エラーしました"
083   error "エラーしました" number -200
084end try
085if listResponse = {} then
086   log "何も選択していない"
087   error "何も選択していない"
088else if (item 1 of listResponse) is false then
089   return "キャンセルしました"
090   error "キャンセルしました" number -200
091else
092   set strValue to (ocidPkgDict's valueForKey:(item 1 of listResponse)) as text
093end if
094
095##############################
096###ダイアログを前面に出す
097tell current application
098   set strName to name as text
099end tell
100###スクリプトメニューから実行したら
101if strName is "osascript" then
102   tell application "Finder" to activate
103else
104   tell current application to activate
105end if
106
107set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
108set strMes to ("パッケージURL eap 戻り値です\rURL\r" & strValue & "\r\r OKSafariでダウンロードします") as text
109set recordResult to (display dialog strMes with title "URL" default answer strValue buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 20 with icon aliasIconPath without hidden answer)
110if button returned of recordResult is "クリップボードにコピー" then
111   try
112      set strText to text returned of recordResult as text
113      ####ペーストボード宣言
114      set appPasteboard to refMe's NSPasteboard's generalPasteboard()
115      set ocidText to (refMe's NSString's stringWithString:(strText))
116      appPasteboard's clearContents()
117      appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
118   on error
119      tell application "Finder"
120         set the clipboard to strTitle as text
121      end tell
122   end try
123end if
124###OKだったらサファリでダウンロード
125if button returned of recordResult is "OK" then
126   tell application "Safari"
127      open location strValue
128   end tell
129end if

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat 2024 Acrobat AddOn Acrobat Annotation Acrobat AppleScript Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat GentechAI Acrobat JS Acrobat JS Word Search Acrobat Maintenance Acrobat Manifest Acrobat Menu Acrobat Merge Acrobat Open Acrobat PDFPage Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat Print Acrobat Python Acrobat Reader Acrobat Reader Localized Acrobat Reference Acrobat Registered Products Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat URL List Mac Acrobat URL List Windows Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin ConfigCode Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin NetWork Admin Permission Admin Pkg Admin Power Management Admin Printer Admin Printer Basic Admin Printer Custompapers Admin SetUp Admin SMB Admin softwareupdate Admin Support Admin System Information Admin TCC Admin Tools Admin Umask Admin Users Admin Volumes Admin XProtect Adobe Adobe AUSST Adobe Bridge Adobe Documents Adobe FDKO Adobe Fonts Adobe Reference Adobe RemoteUpdateManager Adobe Sap Code AppKit Apple AppleScript AppleScript Duplicate AppleScript entire contents AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Video Applications AppStore Archive Archive Keka Attributes Automator BackUp Barcode Barcode Decode Barcode QR Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome Chromedriver CIImage CityCode CloudStorage Color Color NSColor Color NSColorList com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Desktop Position Device Diff Disk do shell script Dock Dock Launchpad DropBox Droplet eMail Encode % Encode Decode Encode HTML Entity Encode UTF8 Error EXIFData exiftool ffmpeg File File Name Finder Finder Window Firefox Folder FolderAction Font List FontCollections Fonts Fonts Asset_Font Fonts ATS Fonts Emoji Fonts Maintenance Fonts Morisawa Fonts Python Fonts Variable Foxit GIF github Guide HTML Icon Icon Assets.car Illustrator Image Events ImageOptim Input Dictionary iPhone iWork Javascript Jedit Ω Json Label Language Link locationd lsappinfo m3u8 Mail Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Microsoft Fonts Microsoft Office Microsoft Office Link Microsoft OneDrive Microsoft Teams Mouse Music Node Notes NSArray NSArray Sort NSAttributedString NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSGraphicsContext Crop NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMetadataItem NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSet NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSUbiquitous NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth PDF PDF Image2PDF PDF MakePDF PDF nUP PDF Pymupdf PDF Pypdf PDFContext PDFDisplayBox PDFImageRep PDFKit PDFKit Annotation PDFKit AnnotationWidget PDFKit DocumentPermissions PDFKit OCR PDFKit Outline PDFKit Start PDFPage PDFPage Rotation PDFView perl Photoshop PlistBuddy pluginkit plutil postalcode PostScript PowerShell prefPane Preview Python Python eyed3 Python pip QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver Script Editor Script Menu SF Symbols character id SF Symbols Entity Shortcuts Shortcuts Events sips Skype Slack Sound Spotlight sqlite StandardAdditions StationSearch Subtitles LRC Subtitles SRT Subtitles VTT Swift swiftDialog System Events System Settings TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom Weather webarchive webp Wifi Windows XML XML EPUB XML HTML XML LSSharedFileList XML LSSharedFileList sfl2 XML LSSharedFileList sfl3 XML objectsForXQuery XML OPML XML Plist XML Plist System Events XML RSS XML savedSearch XML SVG XML TTML XML webloc XML xmllint XML XMP YouTube Zero Padding zoom