sambala 0.9.5 → 0.9.6

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.
@@ -28,8 +28,7 @@
28
28
  # :host => 'sambaserver',
29
29
  # :share => 'sambashare',
30
30
  # :user => 'walrus',
31
- # :password => 'eggman',
32
- # :threads => 2 )
31
+ # :password => 'eggman')
33
32
  #
34
33
  # samba.cd('myfolder') # => true
35
34
  # samba.put(:from => 'aLocalFile.txt') # => [false, "aLocalFile.txt does not exist\r\n"]
@@ -60,19 +59,16 @@ class Sambala
60
59
  # * :host = the hostname of the smb server, may be IP or fully qualified domain name
61
60
  # * :user = the user name to log into the server
62
61
  # * :password = the password to log into the server
63
- # * :threads = how many parallel operations you want initiated, !!! higher than 4 at you own risk !!!
64
62
  # === Example
65
63
  # samba = Sambala.new( :domain => 'NTDOMAIN',
66
64
  # :host => 'sambaserver',
67
65
  # :share => 'sambashare',
68
66
  # :user => 'walrus',
69
- # :password => 'eggman',
70
- # :threads => 2 )
71
- def initialize(options={:domain => '', :host => '', :share => '', :user => '', :password => '', :threads => 1})
67
+ # :password => 'eggman')
68
+ def initialize(options={:domain => '', :host => '', :share => '', :user => '', :password => ''})
72
69
  $log_sambala = GlobaLog.logger(STDERR,:warn)
73
70
  begin
74
- options[:threads] = 4 if options[:threads] > 4
75
- options[:init_timeout] = options[:threads]
71
+ options[:init_timeout] = 1
76
72
  @options = options; gardener_ok
77
73
  rescue
78
74
  @gardener.close unless @gardener.nil? || @gardener.class != 'Gardener'
@@ -106,14 +106,14 @@ class Sambala
106
106
 
107
107
  # The +init_gardener+ method initialize a gardener class object
108
108
  def init_gardener
109
- @gardener = Abundance.gardener(:rows => @options[:threads], :init_timeout => @options[:init_timeout]) do
109
+ @gardener = Abundance.gardener(:rows => 1, :init_timeout => @options[:init_timeout]) do
110
110
 
111
111
  PTY.spawn("smbclient //#{@options[:host]}/#{@options[:share]} #{@options[:password]} -W #{@options[:domain]} -U #{@options[:user]}") do |r,w,pid|
112
112
  w.sync = true
113
113
  $expect_verbose = false
114
114
  catch :init do
115
115
  loop do
116
- r.expect(/.*\xD\xAsmb:[ \x5C]*\x3E.*/) do |text|
116
+ r.expect(/.*\xD\xAsmb\x3A\s[\x5C]*\x3E.*/) do |text|
117
117
  if text != nil
118
118
  text[0] =~ /.*Server=.*/i ? Abundance.init_status(true,"#{text.inspect}") : Abundance.init_status(false,"#{text.inspect}")
119
119
  throw :init
@@ -122,18 +122,27 @@ class Sambala
122
122
  end
123
123
  end
124
124
  Abundance.grow do |seed|
125
+ prompt = false
126
+ until prompt
127
+ w.print "\r"
128
+ r.expect(/.*\xD\xAsmb\x3A\s[\x5C]*\w*[\x5C]+\x3E.*/) do |text|
129
+ if text != nil
130
+ prompt = true
131
+ end
132
+ end
133
+ end
125
134
  w.print "#{seed.sprout}\r"; $log_sambala.debug("smbclient") {"sprout: -- #{seed.sprout} --"}
126
135
  catch :result do
127
136
  iter = 1
128
137
  loop do
129
- r.expect(/.*\xD\xAsmb: [\x5C]*\w*[\x5C]+\x3E.*/) do |text|
130
- $log_sambala.debug("smbclient") {"expect: -- #{text} --"}
138
+ r.expect(/.*\xD\xAsmb\x3A\s[\x5C]*\w*[\x5C]+\x3E.*/) do |text|
139
+ $log_sambala.debug("smbclient") {"expect: -- #{text.inspect} --"}
131
140
  if text != nil
132
141
  msg = text[0]
133
142
 
134
- msg.gsub!(/smb: \w*\x5C\x3E\s*$/, '')
143
+ msg.gsub!(/smb\x3A\s\w*\x5C\x3E\s*$/, '')
135
144
  msg.gsub!(/^\s*#{seed.sprout}/, '')
136
- msg.lstrip!; $log_sambala.debug("smbclient") {"msg: -- #{msg} --"}
145
+ msg.lstrip!; $log_sambala.debug("smbclient") {"msg: -- #{msg.inspect} --"}
137
146
 
138
147
  success = case seed.sprout
139
148
  when /^put/
@@ -150,11 +159,12 @@ class Sambala
150
159
 
151
160
  seed.crop(success, msg)
152
161
  throw :result
153
- elsif iter > 20
162
+ elsif iter > 9999
154
163
  $log_sambala.warn("Failed to #{seed.sprout}")
155
164
  seed.crop(false, "Failed to #{seed.sprout}")
156
165
  throw :result
157
166
  else
167
+ $log_sambala.debug("smbclient") {"jumped iter: #{iter.to_s}"}
158
168
  iter += 1
159
169
  end
160
170
  end
@@ -176,7 +186,7 @@ class Sambala
176
186
  pids.each { |pid| Process.kill('HUP', pid)}
177
187
  end
178
188
  @gardener = nil
179
- @options[:threads] -= 1 unless @options[:threads] == 1; @options[:init_timeout] += 1
189
+ @options[:init_timeout] += 1
180
190
  end
181
191
 
182
192
  def posix?(init_message)
@@ -16,7 +16,6 @@ WELCOME = <<TITLE
16
16
 
17
17
  /////////////////////////////////////////////////////////////
18
18
  TITLE
19
- THREADS = 4
20
19
 
21
20
  class TestSambalaMain < Test::Unit::TestCase
22
21
 
@@ -100,8 +99,7 @@ class TestSambalaMain < Test::Unit::TestCase
100
99
  :host => @host,
101
100
  :share => @share,
102
101
  :user => @user,
103
- :password => @password,
104
- :threads => THREADS)
102
+ :password => @password)
105
103
  puts "Connection successfull,\nnow proceding with test:"
106
104
  end
107
105
 
@@ -175,14 +173,14 @@ class TestSambalaMain < Test::Unit::TestCase
175
173
  end
176
174
 
177
175
  def check_queue
178
- jobs = 300
176
+ jobs = 20
179
177
  @log_test.info("Testing queue... (be patient, this will take a couple minutes)")
180
178
  assert_equal(true, @samba.queue_empty?)
181
179
  assert_equal(true, @samba.queue_done?)
182
180
  assert_equal(0,@samba.queue_waiting)
183
181
 
184
182
  files = Array.new(jobs) { |id| "file_" + id.to_s }
185
- content = "01" * 10000
183
+ content = "01" * 10000000
186
184
  files.each do |file|
187
185
  f = File.new("#{TESTDIR}/#{file}",'w')
188
186
  f.puts content
@@ -211,11 +209,11 @@ class TestSambalaMain < Test::Unit::TestCase
211
209
  result = @samba.queue_completed
212
210
  @log_test.debug("queue completed results is: #{result.inspect}")
213
211
  assert_kind_of(Array,result)
214
- 60.times do |n|
212
+ 301.times do |n|
215
213
  break unless result[0].nil?
216
214
  sleep 1
217
215
  result = @samba.queue_completed
218
- flunk("Could not get any queue done...") if n == 59
216
+ flunk("Could not get any queue done...") if n == 300
219
217
  end
220
218
  assert_kind_of(Array,result[0])
221
219
  assert_equal(4,result[0].size)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sambala
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Perron
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-09 00:00:00 -04:00
12
+ date: 2009-03-11 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency