cafe_basics_duo 0.0.37 → 0.0.39

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_basics_duo.rb +56 -26
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb796dc17c7d63e185a702a8ff258c1fbea1896b8c268b3bd72ddf259aef8229
4
- data.tar.gz: 5eab76415b9122a2ebb4980d68704d2aa928a03746d079d2d1e5a1c6fdb7384e
3
+ metadata.gz: c7ea78320bab5a2a6d1f35a574aab41c67fbc22b51cb8bf6dcb4f9f194a555fd
4
+ data.tar.gz: 2bbc4ee8ce16396133bcfed9da180eb1588379f4bd21511273e902eade0c1c1e
5
5
  SHA512:
6
- metadata.gz: b44c8c2796bef4812ad64cf3c01cafe46664d2317b083ac511c18086d8b137f0cde8aa369c54f0f269b019da47d07286f2f528609cc143f03cdbd8771069a7cc
7
- data.tar.gz: a6308a54ed876a01868dbabe503a81a4b50b445f41124160ba5c1ca014f5571b288e7398897d7c437d1df142b581957fe7a3761149a036bcc8351610e643d324
6
+ metadata.gz: 5feb9d123e8e22613fa35029d9c20be5cce9761fdb218b1ba58a5548400c149e02c86644e46a8a5168b11da6175750ad462a0c04b48bd6930a0edf5aba45b51b
7
+ data.tar.gz: ee1221949df05ce7d63d106f73c1728a13a31ef9b050aebdf3a9a310a26eb1fd7cfaa9a3b906b75234a02deef7e1888104e4dfc7fe6fc90d150cb9b1342d42a7
@@ -2190,36 +2190,66 @@ class Wordpress
2190
2190
  puts table[10]
2191
2191
  if table[7].to_i > table[10].to_i
2192
2192
  if @data['포스트설정']['테더링'].checked?
2193
- puts 'tedering ip change...'
2194
- stdout, stderr, status = Open3.capture3('./adb devices')
2195
- if status.success?
2196
- device_id = stdout.split("\n")[1].split("\t")[0]
2197
- puts device_id
2198
- puts 'adb -s '+device_id+' shell svc data disable'
2199
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2200
- sleep(3)
2201
- puts 'adb -s '+device_id+' shell svc data enable'
2202
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2203
- sleep(3)
2204
- puts 'adb ok'
2205
- sleep(8)
2206
- robot_ip = lambda do
2207
- http = HTTP.get('https://www.findip.kr/')
2208
- noko = Nokogiri::HTML(http.to_s)
2209
- if noko.xpath('/html/body/header/h2').text != @my_ip
2210
- @my_ip = noko.xpath('/html/body/header/h2').text
2211
- else
2212
- puts @my_ip
2213
- puts '재시도...'
2214
- sleep(3)
2215
- robot_ip[]
2216
- end
2193
+ puts 'tethering ip change...'
2194
+
2195
+ # ADB devices 확인
2196
+ stdout, stderr, status = Open3.capture3('./adb devices')
2197
+ if status.success?
2198
+ device_id = stdout.split("\n")[1].split("\t")[0]
2199
+ puts device_id
2200
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2201
+
2202
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2203
+ if status2.success?
2204
+ sleep(3)
2205
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2206
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2207
+ sleep(3)
2208
+ puts 'adb ok'
2209
+ sleep(8)
2210
+
2211
+ # IP 확인 및 재시도 (반복문 사용)
2212
+ retry_count = 0
2213
+ max_retries = 5
2214
+ current_ip = nil
2215
+
2216
+ # 무한 루프 방지
2217
+ while retry_count < max_retries
2218
+ begin
2219
+ http = HTTP.get('https://www.findip.kr/')
2220
+ noko = Nokogiri::HTML(http.to_s)
2221
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2222
+
2223
+ puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2224
+
2225
+ # IP가 변경되었으면 @my_ip를 갱신하고 종료
2226
+ if new_ip != @my_ip
2227
+ @my_ip = new_ip
2228
+ puts "IP 변경됨: #{@my_ip}"
2229
+ break
2230
+ else
2231
+ puts 'IP가 변경되지 않음. 재시도...'
2232
+ retry_count += 1
2233
+ sleep(3) # 3초 후 재시도
2234
+ end
2235
+ rescue => e
2236
+ retry_count += 1
2237
+ sleep(3) # 3초 후 재시도
2217
2238
  end
2218
- robot_ip[]
2239
+
2240
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2241
+ if retry_count >= max_retries
2242
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2243
+ end
2244
+ end
2219
2245
  else
2220
- puts 'adb error pass'
2246
+ puts 'Failed to disable data. Error: ' + stderr2
2221
2247
  end
2248
+ else
2249
+ puts 'adb error, unable to get devices. Error: ' + stderr
2250
+ end
2222
2251
  end
2252
+
2223
2253
 
2224
2254
  check_success = 1
2225
2255
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.37
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon