depot3 0.0.0a1 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -1
- data/bin/d3 +323 -0
- data/bin/d3admin +1011 -0
- data/bin/d3helper +354 -0
- data/bin/puppytime +334 -0
- data/data/d3/com.pixar.d3.RepoMan.plist +23 -0
- data/data/d3/d3.conf.example +507 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftAppKit.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCore.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCoreData.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCoreGraphics.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftCoreImage.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftDarwin.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftDispatch.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftFoundation.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Frameworks/libswiftObjectiveC.dylib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Info.plist +56 -0
- data/data/d3/d3RepoMan.app/Contents/MacOS/d3RepoMan +0 -0
- data/data/d3/d3RepoMan.app/Contents/PkgInfo +1 -0
- data/data/d3/d3RepoMan.app/Contents/Resources/Base.lproj/MainMenu.nib +0 -0
- data/data/d3/d3RepoMan.app/Contents/Resources/last-foreground-times-template.plist +5 -0
- data/data/d3/d3RepoMan.app/Contents/_CodeSignature/CodeResources +214 -0
- data/data/d3/puppytime/ImageLicenses.txt +165 -0
- data/data/d3/puppytime/notification_image +1 -0
- data/data/d3/puppytime/opt_out_image +1 -0
- data/data/d3/puppytime/slideshow/2008-07-11_White_German_Shepherd_pup_chilling_at_the_Coker_Arboretum.jpg +0 -0
- data/data/d3/puppytime/slideshow/2009-04-21_APBT_pup_on_deck.jpg +0 -0
- data/data/d3/puppytime/slideshow/A_puppy_Yorkie.jpg +0 -0
- data/data/d3/puppytime/slideshow/Alert_Pug_Puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Australian_Cattle_Dog_puppies_04.JPG +0 -0
- data/data/d3/puppytime/slideshow/Beagle_puppy_Cadet.jpg +0 -0
- data/data/d3/puppytime/slideshow/Bernese_Mountain_Dog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Bloodhound_Puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Boston_terrier_with_toy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Boxer_puppy_fawn_portrai.jpg +0 -0
- data/data/d3/puppytime/slideshow/Caracal_kitten.jpg +0 -0
- data/data/d3/puppytime/slideshow/Chihuahua_&_Doberman_Pup.jpg +0 -0
- data/data/d3/puppytime/slideshow/Cuccioli_di_Margot_a_35_gg_Basenjis.jpg +0 -0
- data/data/d3/puppytime/slideshow/Dalmatian_puppy_03.jpg +0 -0
- data/data/d3/puppytime/slideshow/GoldenRetrieverPuppyDaisyParker.JPG +0 -0
- data/data/d3/puppytime/slideshow/Green_eyed_beige_Chihuahua.jpg +0 -0
- data/data/d3/puppytime/slideshow/Let_Sleeping_Dogs_Lie.jpg +0 -0
- data/data/d3/puppytime/slideshow/Meatball_-_French_Bulldog_Puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Oola_-_9_weeks.jpg +0 -0
- data/data/d3/puppytime/slideshow/Pancho0008.JPG +0 -0
- data/data/d3/puppytime/slideshow/Pomeranian_orange-sable_Coco.jpg +0 -0
- data/data/d3/puppytime/slideshow/Pug_puppy_001.jpg +0 -0
- data/data/d3/puppytime/slideshow/Puggle_puppy_6_weeks.JPG +0 -0
- data/data/d3/puppytime/slideshow/Puli_kan.jpg +0 -0
- data/data/d3/puppytime/slideshow/Puppy_French_Bulldog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Rocco_the_Bulldog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Rottweiler_Face.jpg +0 -0
- data/data/d3/puppytime/slideshow/Saint_Bernard_puppy.jpg +0 -0
- data/data/d3/puppytime/slideshow/Scottish_froment.jpg +0 -0
- data/data/d3/puppytime/slideshow/Shar_pei_puppy_(age_2_months).jpg +0 -0
- data/data/d3/puppytime/slideshow/Shiba-Inu_beim_Spielen_im_Schnee.JPG +0 -0
- data/data/d3/puppytime/slideshow/Smooth-coat_Border_Collie_puppy..jpg +0 -0
- data/data/d3/puppytime/slideshow/Smooth_Dachshund_puppies.jpg +0 -0
- data/data/d3/puppytime/slideshow/Snow_dog.jpg +0 -0
- data/data/d3/puppytime/slideshow/Taylor_the_Pembroke_Welsh_Corgi.png +0 -0
- data/data/d3/puppytime/slideshow/Weim_Pups_001.jpg +0 -0
- data/data/d3/puppytime/slideshow/Westie_pups.jpg +0 -0
- data/data/d3/puppytime/slideshow/Yellow_Labrador_puppies_(4165737325).jpg +0 -0
- data/lib/d3/admin/add.rb +451 -0
- data/lib/d3/admin/auth.rb +470 -0
- data/lib/d3/admin/edit.rb +297 -0
- data/lib/d3/admin/help.rb +396 -0
- data/lib/d3/admin/interactive.rb +972 -0
- data/lib/d3/admin/options.rb +454 -0
- data/lib/d3/admin/prefs.rb +204 -0
- data/lib/d3/admin/report.rb +727 -0
- data/lib/d3/admin/state.rb +42 -0
- data/lib/d3/admin/validate.rb +413 -0
- data/lib/d3/admin.rb +42 -0
- data/lib/d3/basename.rb +217 -0
- data/lib/d3/client/auth.rb +108 -0
- data/lib/d3/client/class_methods.rb +766 -0
- data/lib/d3/client/class_variables.rb +47 -0
- data/lib/d3/client/cli.rb +187 -0
- data/lib/d3/client/environment.rb +134 -0
- data/lib/d3/client/help.rb +110 -0
- data/lib/d3/client/lists.rb +314 -0
- data/lib/d3/client/receipt.rb +1173 -0
- data/lib/d3/client.rb +45 -0
- data/lib/d3/configuration.rb +319 -0
- data/lib/d3/constants.rb +60 -0
- data/lib/d3/database.rb +488 -0
- data/lib/d3/exceptions.rb +44 -0
- data/lib/d3/log.rb +271 -0
- data/lib/d3/package/aliases.rb +80 -0
- data/lib/d3/package/attributes.rb +97 -0
- data/lib/d3/package/class_methods.rb +817 -0
- data/lib/d3/package/class_variables.rb +46 -0
- data/lib/d3/package/client_actions.rb +293 -0
- data/lib/d3/package/constants.rb +58 -0
- data/lib/d3/package/constructor.rb +191 -0
- data/lib/d3/package/getters.rb +164 -0
- data/lib/d3/package/mixins.rb +39 -0
- data/lib/d3/package/private_methods.rb +227 -0
- data/lib/d3/package/questions.rb +95 -0
- data/lib/d3/package/server_actions.rb +683 -0
- data/lib/d3/package/setters.rb +326 -0
- data/lib/d3/package/validate.rb +448 -0
- data/lib/d3/package.rb +51 -0
- data/lib/d3/puppytime/pending_puppy.rb +108 -0
- data/lib/d3/puppytime/puppy_queue.rb +274 -0
- data/lib/d3/puppytime.rb +68 -0
- data/lib/d3/state.rb +105 -0
- data/lib/d3/utility.rb +325 -0
- data/lib/d3/version.rb +1 -1
- metadata +162 -9
@@ -0,0 +1,274 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
|
26
|
+
module D3
|
27
|
+
module PuppyTime
|
28
|
+
### PuppyQ - the current queue of pending puppy installs.
|
29
|
+
### This class only has one real value: A hash of
|
30
|
+
### PendingPuppy objects, keyed by basename.
|
31
|
+
### But, PendingPuppies can be added and removed
|
32
|
+
### and the queue can be read and written to disk
|
33
|
+
###
|
34
|
+
class PuppyQueue
|
35
|
+
|
36
|
+
################# Mixin Modules #################
|
37
|
+
|
38
|
+
include Singleton
|
39
|
+
|
40
|
+
################## Class Constants #################
|
41
|
+
|
42
|
+
QUEUE_FILE = D3::SUPPORT_DIR + "d3-pending-puppies.yaml"
|
43
|
+
|
44
|
+
DFT_NOTIFICATION_FREQUENCY = 7
|
45
|
+
|
46
|
+
################# Class Methods #################
|
47
|
+
|
48
|
+
################# Attributes #################
|
49
|
+
|
50
|
+
# the queue of PendingPuppy objects
|
51
|
+
# A hash, keyed by basename.
|
52
|
+
attr_reader :q
|
53
|
+
|
54
|
+
################# Constructor #################
|
55
|
+
|
56
|
+
# start by sett
|
57
|
+
def initialize
|
58
|
+
read_q
|
59
|
+
end # init
|
60
|
+
|
61
|
+
################# Public Instance Methods #################
|
62
|
+
|
63
|
+
### Read in the current puppy queue from disk
|
64
|
+
### or set it to an empty hash if not there.
|
65
|
+
###
|
66
|
+
### @return [void]
|
67
|
+
###
|
68
|
+
def read_q
|
69
|
+
if QUEUE_FILE.exist?
|
70
|
+
@q = YAML.load(QUEUE_FILE.read)
|
71
|
+
D3.log "Puppy queue loaded from disk", :debug
|
72
|
+
else
|
73
|
+
@q = {}
|
74
|
+
D3.log "Created new empty puppy queue", :debug
|
75
|
+
end
|
76
|
+
end # read_q
|
77
|
+
|
78
|
+
### Save the current q out to disk
|
79
|
+
###
|
80
|
+
def save_q
|
81
|
+
D3.log "Saving puppy queue", :debug
|
82
|
+
if @q.empty?
|
83
|
+
D3.log "Puppy queue is empty, deleting from disk", :debug
|
84
|
+
QUEUE_FILE.delete
|
85
|
+
else
|
86
|
+
QUEUE_FILE.jss_save YAML.dump(@q)
|
87
|
+
D3.log "Puppy queue saved to disk", :debug
|
88
|
+
end
|
89
|
+
|
90
|
+
end # save_q
|
91
|
+
|
92
|
+
### @return [Array<String>] the basenames of the pending puppies
|
93
|
+
###
|
94
|
+
def pups
|
95
|
+
@q.keys
|
96
|
+
end
|
97
|
+
|
98
|
+
### Add a puppy to the queue
|
99
|
+
###
|
100
|
+
### @param puppy[D3::PendingPupppy] the puppy to add.
|
101
|
+
###
|
102
|
+
### @return [Boolean] True if the puppy was queued, false if already
|
103
|
+
### in the queue with a same or newer edition.
|
104
|
+
###
|
105
|
+
def + (puppy)
|
106
|
+
|
107
|
+
raise TypeError, "You can only add PendingPuppy ojects to the PuppyQueue" unless puppy.class == D3::PuppyTime::PendingPuppy
|
108
|
+
|
109
|
+
D3.log "Adding to puppy queue: #{puppy.edition}", :info
|
110
|
+
|
111
|
+
# does this basename already exist in the queue?
|
112
|
+
# we can only have one edition per basename in the queue at a time
|
113
|
+
if pups.include? puppy.basename
|
114
|
+
in_q = @q[puppy.basename]
|
115
|
+
|
116
|
+
# if the pre-queued one is older, replace it with this one.
|
117
|
+
if in_q.id < puppy.id
|
118
|
+
D3.log "Replacing older puppy in queue: #{in_q.edition}", :warm
|
119
|
+
self - puppy.basename
|
120
|
+
else
|
121
|
+
if puppy.force
|
122
|
+
D3.log "Puppy already in queue for '#{puppy.basename}' is the same or newer (#{in_q.edition}), but force-adding", :warn
|
123
|
+
self - puppy.basename
|
124
|
+
else
|
125
|
+
D3.log "Puppy already in queue for '#{puppy.basename}' is the same or newer (#{in_q.edition}), not adding", :warn
|
126
|
+
return false
|
127
|
+
end # if force
|
128
|
+
end
|
129
|
+
end # if @pups.include? puppy.basename
|
130
|
+
|
131
|
+
# note if we're starting with an empty queue
|
132
|
+
started_empty = @q.empty?
|
133
|
+
|
134
|
+
# Note when we're queueing
|
135
|
+
puppy.queued_at = Time.now
|
136
|
+
|
137
|
+
# add the new puppy
|
138
|
+
@q[puppy.basename] = puppy
|
139
|
+
D3.log "Added puppy to queue: #{puppy.edition}", :info
|
140
|
+
|
141
|
+
# save it
|
142
|
+
save_q
|
143
|
+
|
144
|
+
notify_puppies
|
145
|
+
|
146
|
+
return true
|
147
|
+
end # +
|
148
|
+
|
149
|
+
### Remove a puppy from the queue
|
150
|
+
###
|
151
|
+
### @param puppy[String,D3::PendingPupppy] the basename or D3::PendingPupppy
|
152
|
+
### for the puppy to be removed
|
153
|
+
###
|
154
|
+
### @return [Boolean] true if it was removed, false if it wasn't in the queue
|
155
|
+
###
|
156
|
+
def - (puppy)
|
157
|
+
|
158
|
+
puppy = puppy.basename unless puppy.is_a? String
|
159
|
+
|
160
|
+
return false unless pups.include? puppy
|
161
|
+
|
162
|
+
# remove it
|
163
|
+
@q.delete puppy
|
164
|
+
D3.log "Removed basename #{puppy} from the puppy queue", :debug
|
165
|
+
|
166
|
+
# save the queue
|
167
|
+
save_q
|
168
|
+
|
169
|
+
return true
|
170
|
+
end # +
|
171
|
+
|
172
|
+
### Should we run the puppytime notification policy?
|
173
|
+
### returns the policy id or name, or false if we
|
174
|
+
### shouldn't run.
|
175
|
+
###
|
176
|
+
### @return [String,Integer,false] the policy to run, if we should
|
177
|
+
###
|
178
|
+
def should_run_notification_policy
|
179
|
+
# no puppies, no notify
|
180
|
+
if @q.empty?
|
181
|
+
D3.log "Not running puppytime notification policy: No puppies in queue", :debug
|
182
|
+
return false
|
183
|
+
end
|
184
|
+
|
185
|
+
# no policy, no notify
|
186
|
+
unless policy = D3::CONFIG.puppy_notification_policy
|
187
|
+
D3.log "Not running puppytime notification policy: No policy in config", :debug
|
188
|
+
return false
|
189
|
+
end
|
190
|
+
|
191
|
+
# no-notification option was given, no notify
|
192
|
+
unless D3::Client.puppy_notification_ok_with_admin?
|
193
|
+
D3.log "Not running puppytime notification policy: --no-puppy-notification was given", :debug
|
194
|
+
return false
|
195
|
+
end
|
196
|
+
|
197
|
+
# how many days between notifications?
|
198
|
+
frequency = D3::CONFIG.puppy_notification_frequency
|
199
|
+
frequency ||= DFT_NOTIFICATION_FREQUENCY
|
200
|
+
|
201
|
+
case frequency
|
202
|
+
# zero means never notify
|
203
|
+
when 0
|
204
|
+
D3.log "Not running puppytime notification policy: Frequency set to Zero", :debug
|
205
|
+
return false
|
206
|
+
# -1 means always notify
|
207
|
+
when -1
|
208
|
+
D3.log "Frequency set to -1, always running puppytime notification policy", :debug
|
209
|
+
return policy
|
210
|
+
end
|
211
|
+
|
212
|
+
unless last_notification = D3::CONFIG.puppy_last_notification
|
213
|
+
# never been notified? always notify.
|
214
|
+
D3.log "Puppytime notification policy never run, running now.", :debug
|
215
|
+
return policy
|
216
|
+
end # if last notiv
|
217
|
+
|
218
|
+
# not long enough since last? no notify
|
219
|
+
last_notification_days_ago = ((Time.now - last_notification) / 60 / 60 / 24).to_i
|
220
|
+
unless last_notification_days_ago >= frequency
|
221
|
+
D3.log "Not running puppytime notification policy: last notification #{last_notification_days_ago}/#{frequency} days ago", :debug
|
222
|
+
return false
|
223
|
+
end
|
224
|
+
|
225
|
+
return policy
|
226
|
+
end
|
227
|
+
|
228
|
+
### Run the puppy notification policy, if there is one
|
229
|
+
### and if its been long enough since the last run.
|
230
|
+
###
|
231
|
+
### @return [void]
|
232
|
+
###
|
233
|
+
def notify_puppies(verbose = false)
|
234
|
+
|
235
|
+
return unless policy = should_run_notification_policy
|
236
|
+
|
237
|
+
# put the queue editions in the ENV
|
238
|
+
puppies = @q.values.map{|p| p.edition}.join " "
|
239
|
+
D3::Client.set_env :puppytime_notification, puppies
|
240
|
+
|
241
|
+
D3.run_policy policy, :puppy_notification, verbose
|
242
|
+
|
243
|
+
update_last_notification
|
244
|
+
D3::Client.unset_env :puppytime_notification
|
245
|
+
end
|
246
|
+
|
247
|
+
### Update the last notification date in the config
|
248
|
+
### to right-now.
|
249
|
+
###
|
250
|
+
### @return [void]
|
251
|
+
###
|
252
|
+
def update_last_notification
|
253
|
+
D3.log "Updating last puppy notification time", :debug
|
254
|
+
D3::CONFIG.puppy_last_notification = Time.now
|
255
|
+
D3::CONFIG.save
|
256
|
+
end # update last notification
|
257
|
+
|
258
|
+
|
259
|
+
################# Method Aliases #################
|
260
|
+
|
261
|
+
alias queue q
|
262
|
+
alias pending_puppies q
|
263
|
+
alias puppies pups
|
264
|
+
alias basenames pups
|
265
|
+
alias refresh read_q
|
266
|
+
|
267
|
+
end # class PuppyQueue
|
268
|
+
|
269
|
+
end # module puppytime
|
270
|
+
|
271
|
+
# here's our one queue instance
|
272
|
+
PUPPY_Q = D3::PuppyTime::PuppyQueue.instance
|
273
|
+
|
274
|
+
end #module d3
|
data/lib/d3/puppytime.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
require 'd3/puppytime/pending_puppy'
|
26
|
+
require 'd3/puppytime/puppy_queue'
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
module D3
|
31
|
+
|
32
|
+
# Constants and methods for PuppyTime, which installs the pkgs listed in the
|
33
|
+
# PuppyQueue at logout.
|
34
|
+
#
|
35
|
+
module PuppyTime
|
36
|
+
|
37
|
+
################# Module Constants #################
|
38
|
+
|
39
|
+
DFT_IMAGE_DIR = D3::SUPPORT_DIR + "puppytime"
|
40
|
+
|
41
|
+
DFT_OPTOUT_IMAGE = DFT_IMAGE_DIR + "opt_out_image"
|
42
|
+
|
43
|
+
DFT_NOTIFY_IMAGE = DFT_IMAGE_DIR + "notification_image"
|
44
|
+
|
45
|
+
DFT_SLIDESHOW_DIR = DFT_IMAGE_DIR + "slideshow"
|
46
|
+
|
47
|
+
DFT_OPTOUT_TEXT = "Software updates will start when you click OK,\nor when the timer runs out.\nClick cancel to postpone till next logout"
|
48
|
+
|
49
|
+
DFT_OPTOUT_SECS = 30
|
50
|
+
|
51
|
+
DFT_DISPLAY_SECS = 8
|
52
|
+
|
53
|
+
DFT_TITLE = "PuppyTime!"
|
54
|
+
|
55
|
+
DFT_IMG_SIZE = 250
|
56
|
+
|
57
|
+
TEXT_POSITION = :center
|
58
|
+
|
59
|
+
DFT_CAPTION = "The puppies are..."
|
60
|
+
|
61
|
+
CAPTION_POSITION = :left
|
62
|
+
|
63
|
+
COUNTDOWN_POSITION = :right
|
64
|
+
|
65
|
+
end #module PuppyTime
|
66
|
+
|
67
|
+
end #module D3
|
68
|
+
|
data/lib/d3/state.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
|
26
|
+
module D3
|
27
|
+
|
28
|
+
# this will be set to true when we finish loading
|
29
|
+
@@loaded = false
|
30
|
+
|
31
|
+
def self.loaded?
|
32
|
+
@@loaded
|
33
|
+
end
|
34
|
+
|
35
|
+
# This stores the current level of log messages
|
36
|
+
# sent to stdout. See
|
37
|
+
# D3::Log.level to set the level for messages
|
38
|
+
# sent to the log.
|
39
|
+
# @return [Integer]
|
40
|
+
@@verbosity = D3::Log::DFT_VERBOSITY
|
41
|
+
|
42
|
+
def self.verbosity
|
43
|
+
@@verbosity
|
44
|
+
end
|
45
|
+
|
46
|
+
### Set the level of verbosity to stderr.
|
47
|
+
### Messages logged via D3#log, of this severity and higher,
|
48
|
+
### will show up on stderr
|
49
|
+
### They *may* show up in the log depending on the D3::LOG.level
|
50
|
+
###
|
51
|
+
### @param new_verbosity[Symbol, Integer] the new value, one of D3::Log::LOG_LEVELS
|
52
|
+
###
|
53
|
+
### @return [void]
|
54
|
+
###
|
55
|
+
def self.verbosity= (new_val)
|
56
|
+
# range is 0-4 if we're given an integer
|
57
|
+
# so force it to be in the range.
|
58
|
+
if new_val.is_a? Fixnum
|
59
|
+
new_val = 0 if new_val < 0
|
60
|
+
new_val = 4 if new_val > 4
|
61
|
+
end
|
62
|
+
@@verbosity = D3::Log.check_level(new_val)
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
# have we been asked to be forceful, and perform
|
67
|
+
# unnatural acts?
|
68
|
+
# Force is used in many different was in many places
|
69
|
+
# so we'll store it here and anything can access it
|
70
|
+
# using D3::force, D3::unforce, and D3::forced?
|
71
|
+
@@force = false
|
72
|
+
|
73
|
+
def self.force
|
74
|
+
@@force = true
|
75
|
+
D3::Client.set_env :force
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.unforce
|
79
|
+
@@force = false
|
80
|
+
D3::Client.unset_env :force
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.forced?
|
84
|
+
@@force
|
85
|
+
end
|
86
|
+
|
87
|
+
### Are we connected to the API and DB servers?
|
88
|
+
###
|
89
|
+
### returns false if the are not both connected
|
90
|
+
### returns a hash like this if both are connected:
|
91
|
+
###
|
92
|
+
### {:api => "user@api_server", :db => "sql_user@db_server"}
|
93
|
+
###
|
94
|
+
### @return [false, Hash] Are we connected to the servers, and if so,
|
95
|
+
### what hosts and usernames
|
96
|
+
###
|
97
|
+
def self.connected?
|
98
|
+
return false unless JSS::API.connected? and JSS::DB_CNX.connected?
|
99
|
+
return {
|
100
|
+
:api => (JSS::API.cnx.options[:user] + "@" + JSS::API.cnx.options[:server]),
|
101
|
+
:db => (JSS::DB_CNX.user + "@" + JSS::DB_CNX.server)
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
end # module
|