Advertisement
applehelpwriter

iCloud Daemon Status script

Mar 1st, 2017
1,716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###########################################################
  2. -->> ABOUT
  3. ###########################################################
  4. (*
  5.  
  6. Phil Stokes -- 2017
  7. applehelpwriter.com
  8. sqwarq.com
  9.  
  10. *)
  11. ###########################################################
  12. -->> DESCRIPTION
  13. ###########################################################
  14. (*
  15.  
  16. Tells you what iCloud daemon is doing. If files are pending update or being updated, it will tell you which ones. It will also tell you if the iCloud daemon is either idle or busy / not responding.
  17.  
  18. *)
  19. ###########################################################
  20. -->> USAGE
  21. ###########################################################
  22. (*
  23.  
  24. Click 'Run' to execute
  25.  
  26. *)
  27. ###########################################################
  28. -->> IMPORT STATEMENTS
  29. ###########################################################
  30.  
  31. use AppleScript version "2.4" -- Yosemite (10.10) or later
  32. use scripting additions
  33.  
  34. ###########################################################
  35. -->> VARIABLES
  36. ###########################################################
  37. set d to (current date) as text
  38. set tempList to {}
  39. set busyMessage to d & return & "iCloud daemon is busy. Try again in a few moments."
  40.  
  41. ###########################################################
  42. -->> HANDLERS
  43. ###########################################################
  44.  
  45. on iCloudFileNameFor:anItem
  46. set anItem to anItem as text
  47. set o to offset of "sz:" in anItem
  48. set anItem to text o thru -1 of anItem
  49. set o to offset of " n:" in anItem
  50. set anItem to text (o + 4) thru -1 of anItem
  51. set o to offset of "\"" in anItem
  52. set anItem to text 1 thru (o - 1) of anItem
  53. return anItem
  54. end iCloudFileNameFor:
  55.  
  56. on errorTrap1()
  57. try
  58. set r to do shell script "brctl status | wc -l"
  59. set ro to r as integer
  60. if r > 49 then
  61. return "iCloud is uploading..."
  62. else
  63. return "iCloud is not updating."
  64. end if
  65. on error
  66. return my busyMessage
  67. end try
  68. end errorTrap1
  69.  
  70.  
  71. ###########################################################
  72. -->> COMMANDS
  73. ###########################################################
  74. set e to 1
  75. try
  76. set f to do shell script "brctl status | grep needs-upload"
  77. set e to 2
  78. on error
  79. set e to 3
  80. end try
  81.  
  82.  
  83. if e = 1 then
  84. set f to my busyMessage
  85. else if e = 2 then
  86. set f to paragraphs of f
  87. repeat with i from 1 to count of f
  88. set this_item to item i of f
  89. set itemName to (my iCloudFileNameFor:this_item)
  90. set end of tempList to itemName
  91. end repeat
  92. set f to tempList
  93. else
  94. set f to my errorTrap1()
  95. end if
  96.  
  97. if e = 2 then
  98. set n to (count of f) as text
  99. if n > 1 then
  100. set i to " items "
  101. else
  102. set i to " item "
  103. end if
  104. set aPrompt to n & i & "pending update:"
  105. choose from list f with title "iCloud Status" with prompt aPrompt OK button name "Done" with empty selection allowed
  106. else
  107. display dialog f with title "iCloud Status" buttons {"OK"} default button "OK"
  108. end if
  109.  
  110.  
  111. ###########################################################
  112. #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement