henchman-sync 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34113b7a846cd62928aa75e9698a466ee237357f
4
- data.tar.gz: 2b0ca4b2d1bb0212c6072c399f5ed8db8278d7a5
3
+ metadata.gz: 268f8796ffcc52cc93450042d33c1303b5620b8b
4
+ data.tar.gz: 26b828d81890a194303180767bad326a1c863621
5
5
  SHA512:
6
- metadata.gz: 74ca677b0cffdcc6fb94947f1a248e53ef2ca074e8b41472b92fa53d33b11e3b1bff1ae4cc2783397a33b0b45fde5ea30f0328877515d91c4a5d68514f4f49f3
7
- data.tar.gz: bab19023bb414a722b905540479d1297ddd9fa25983c239ca112b3eb8a9114316211332a0ec49aedb8b900198f1a99103062fcb422580a2f5afa27c835ef0667
6
+ metadata.gz: 678c2e611262bfc9236c7bbee2bf9cda2be634389322f9a1180a373ba0b052549f03440125566c01ff87fb67c19189d24cdb7400931a02923fa8f0c79c560831
7
+ data.tar.gz: a37aeb86dce167e4e509d723d01157637374d366773e3cfb287c6164b46c02d26a50b2372be038dd5c68bbc84a0215c335a5f267da5065b8ba90f44443ed8a69
data/lib/applescript.rb CHANGED
@@ -275,9 +275,13 @@ module Henchman
275
275
  end
276
276
 
277
277
  def set_track_location selection, local_file
278
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
279
+ "Updating location of #{selection.reject{|k,v| k == :path || k == :id}.values.join(':')} to #{local_file}"
280
+
278
281
  ret = %x(#{applescript_command(update_track_location_script selection[:id], local_file)}).chomp
279
282
  if ret.empty? || ret == '0'
280
- puts "Could not update location of #{selection.values.join(':')} to #{local_file}"
283
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
284
+ "Could not update location of #{selection.reject{|k,v| k == :path || k == :id}.values.join(':')} to #{local_file}"
281
285
  false
282
286
  else
283
287
  true
data/lib/cache.rb CHANGED
@@ -13,7 +13,8 @@ module Henchman
13
13
 
14
14
  @cache[:ignore].each_value { |val| val.default = 0 }
15
15
  rescue StandardError => err
16
- puts "Error opening cache file (#{err})"
16
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
17
+ "Error opening cache file (#{err})"
17
18
  @cache = Henchman::Templates.cache
18
19
  end
19
20
  @cache[:history].default = DateTime.new
@@ -51,7 +52,8 @@ module Henchman
51
52
 
52
53
  def valid_ignore_type? type
53
54
  if !(Henchman::Templates.cache[:ignore].keys.include? type)
54
- puts "Invalid type '#{type}' for ignore cache check"
55
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
56
+ "Invalid type '#{type}' for ignore cache check"
55
57
  false
56
58
  else
57
59
  true
data/lib/clean.rb CHANGED
@@ -8,7 +8,8 @@ module Henchman
8
8
 
9
9
  def self.run played_date
10
10
 
11
- puts "Cleanup ran at #{DateTime.now.strftime('%m-%d-%Y %k:%M:%S%p')}"
11
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
12
+ "Cleanup Starting"
12
13
 
13
14
  played_date = (played_date == 'true') ? true : false
14
15
 
@@ -19,7 +20,8 @@ module Henchman
19
20
  @cache.config @config
20
21
  @appleScript.setup @config
21
22
  rescue StandardError => err
22
- puts "Error opening config file. Try rerunning `henchman configure`"
23
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
24
+ "Error opening config file. Try rerunning `henchman configure`"
23
25
  return
24
26
  end
25
27
 
@@ -35,19 +37,24 @@ module Henchman
35
37
 
36
38
  @cache.flush
37
39
 
40
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
41
+ "Cleanup Finished"
42
+
38
43
  end
39
44
 
40
45
  def self.cleanup track
41
46
  filepath = track[:path]
42
47
  File.delete filepath
43
48
  @cache.delete track
44
- puts "Deleted #{filepath}"
49
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
50
+ "Deleted #{filepath}"
45
51
 
46
52
  while File.dirname(filepath) != @config[:root]
47
53
  filepath = File.dirname(filepath)
48
54
  begin
49
55
  Dir.rmdir(filepath)
50
- puts "Deleted #{filepath}"
56
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
57
+ "Deleted #{filepath}"
51
58
  rescue SystemCallError => msg
52
59
  break
53
60
  end
data/lib/core.rb CHANGED
@@ -18,7 +18,8 @@ module Henchman
18
18
  @config = YAML.load_file(File.expand_path('~/.henchman/config'))
19
19
  @cache.config @config
20
20
  rescue StandardError => err
21
- puts "Error opening config file. Try rerunning `henchman configure`"
21
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
22
+ "Error opening config file. Try rerunning `henchman configure`"
22
23
  return
23
24
  end
24
25
 
@@ -26,7 +27,8 @@ module Henchman
26
27
  begin
27
28
  @dropbox = Henchman::DropboxAssistant.new @config
28
29
  rescue
29
- puts "Error connecting to Dropbox. Try rerunning `henchman configure`"
30
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
31
+ "Error connecting to Dropbox. Try rerunning `henchman configure`"
30
32
  return
31
33
  end
32
34
 
@@ -65,7 +67,7 @@ module Henchman
65
67
  end
66
68
  end
67
69
  rescue StandardError => err
68
- puts err
70
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|#{err}"
69
71
  next
70
72
  end
71
73
  end
@@ -100,6 +102,7 @@ module Henchman
100
102
 
101
103
  def self.itunes_is_active?
102
104
  @appleScript.get_active_app == 'iTunes'
105
+ # true
103
106
  end
104
107
 
105
108
  def self.download_tracks album_tracks
@@ -121,7 +124,7 @@ module Henchman
121
124
  cleanup file_save_path, track if !updated
122
125
  end
123
126
  rescue StandardError => err
124
- puts err
127
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|#{err}"
125
128
  end
126
129
  end
127
130
 
data/lib/dropbox.rb CHANGED
@@ -12,15 +12,17 @@ module Henchman
12
12
  @client = DropboxClient.new(@config[:dropbox][:access_token])
13
13
  true
14
14
  rescue DropboxError => msg
15
- puts "Couldn't connect to Dropbox (#{msg}). \n"\
16
- "Run `henchman stop` then `henchman configure` \n"\
15
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
16
+ "Couldn't connect to Dropbox (#{msg}). "\
17
+ "Run `henchman stop` then `henchman configure` "\
17
18
  "to configure Dropbox connection."
18
19
  false
19
20
  end
20
21
  end
21
22
 
22
23
  def download selection, dropbox_path
23
- puts "downloading #{selection[:track]}"
24
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
25
+ "Downloading #{selection.reject{|k,v| k == :path || k == :id}.values.join(':')}"
24
26
  begin
25
27
  # download the file
26
28
  content = @client.get_file(dropbox_path)
@@ -34,20 +36,25 @@ module Henchman
34
36
  open(file_save_path, 'w') {|f| f.puts content }
35
37
  file_save_path
36
38
  rescue DropboxError => msg
37
- puts "Error downloading Dropbox file #{dropbox_path}: #{msg}"
39
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
40
+ "Error downloading Dropbox file #{dropbox_path}: #{msg}"
38
41
  false
39
42
  rescue StandardError => msg
40
- puts "Error saving Dropbox file #{dropbox_path} to #{trgt_dir}: #{msg}"
43
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
44
+ "Error saving Dropbox file #{dropbox_path} to #{trgt_dir}: #{msg}"
41
45
  false
42
46
  end
43
47
  end
44
48
 
45
49
  def search_for selection
50
+ puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|"\
51
+ "Searching for #{selection.reject{|k,v| k == :path || k == :id}.values.join(':')}"
52
+
46
53
  # search Dropbox for the file
47
54
  begin
48
55
  results = @client.search(@config[:dropbox][:root], selection[:track])
49
56
  rescue DropboxError => msg
50
- raise "Error accessing Dropbox Search API on #{selection.values.join(':')}: #{msg}"
57
+ raise "Error accessing Dropbox Search API on #{selection.reject{|k,v| k == :path || k == :id}.values.join(':')}: #{msg}"
51
58
  end
52
59
 
53
60
  # get rid of any results that are directories
@@ -1,3 +1,3 @@
1
1
  module Henchman
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -34,23 +34,29 @@ module Henchman
34
34
  `launchctl load #{plist_path_clean}`
35
35
 
36
36
  puts "Launched successfully! You are now running henchman."
37
+ open(File.expand_path("~/.henchman/stdout.log"), 'a') do |f|
38
+ f.puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|Henchman Started"
39
+ end
37
40
  end
38
41
 
39
42
  def self.stop
40
43
  puts "Stopping agents"
41
44
  plist_path_main = File.expand_path("~/Library/LaunchAgents/com.henchman.plist")
42
45
  plist_path_clean = File.expand_path("~/Library/LaunchAgents/com.henchman.clean.plist")
43
- `launchctl unload #{plist_path_main}`
44
- `launchctl unload #{plist_path_clean}`
45
- `rm #{plist_path_main}`
46
- `rm #{plist_path_clean}`
47
- `rm #{File.expand_path("~/.henchman/run.sh")}`
48
- `rm #{File.expand_path("~/.henchman/clean.sh")}`
49
- `rm #{File.expand_path("~/.henchman/cache")}`
50
- `rm #{File.expand_path("~/.henchman/stdout.log")}`
51
- `rm #{File.expand_path("~/.henchman/stderr.log")}`
46
+ `launchctl unload #{plist_path_main} 2> /dev/null`
47
+ `launchctl unload #{plist_path_clean} 2> /dev/null`
48
+ `rm #{plist_path_main} 2> /dev/null`
49
+ `rm #{plist_path_clean} 2> /dev/null`
50
+ `rm #{File.expand_path("~/.henchman/run.sh")} 2> /dev/null`
51
+ `rm #{File.expand_path("~/.henchman/clean.sh")} 2> /dev/null`
52
+ `rm #{File.expand_path("~/.henchman/cache")} 2> /dev/null`
53
+ # `rm #{File.expand_path("~/.henchman/stdout.log")} 2> /dev/null`
54
+ # `rm #{File.expand_path("~/.henchman/stderr.log")} 2> /dev/null`
52
55
 
53
56
  puts "Successfully stopped henchman"
57
+ open(File.expand_path("~/.henchman/stdout.log"), 'a') do |f|
58
+ f.puts "#{DateTime.now.strftime('%m-%d-%Y %H:%M:%S')}|Henchman Stopped"
59
+ end
54
60
  end
55
61
 
56
62
  def self.internet_connection?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: henchman-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Merritt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-01 00:00:00.000000000 Z
11
+ date: 2016-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander