cafe_basics_duo 0.0.36 → 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 +61 -26
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3a697ba557074c8b05516900b85472050876f914d4d7eb26853039241b07086
4
- data.tar.gz: b0ee2751afbc19da9a8cdee3ac73db5c0eea81a6c4908ad3f37a0133c58f7fea
3
+ metadata.gz: c7ea78320bab5a2a6d1f35a574aab41c67fbc22b51cb8bf6dcb4f9f194a555fd
4
+ data.tar.gz: 2bbc4ee8ce16396133bcfed9da180eb1588379f4bd21511273e902eade0c1c1e
5
5
  SHA512:
6
- metadata.gz: d9edc1b3d48c1e8df1af63a3b6081b87b08f2b2edd806cbcc3355b736e915850eb85bffb11052352034bc1d8377e0cfacb6a7c089711c90c0053ed6029fc68ee
7
- data.tar.gz: 0acf8d54454a6e3b9bc4c9ddacd8d6d39a3291afb109657be50243e11fd2a3f6623d422983e6b6d6c8ddb26a3784da8640300c49cedf63306651df7496849f94
6
+ metadata.gz: 5feb9d123e8e22613fa35029d9c20be5cce9761fdb218b1ba58a5548400c149e02c86644e46a8a5168b11da6175750ad462a0c04b48bd6930a0edf5aba45b51b
7
+ data.tar.gz: ee1221949df05ce7d63d106f73c1728a13a31ef9b050aebdf3a9a310a26eb1fd7cfaa9a3b906b75234a02deef7e1888104e4dfc7fe6fc90d150cb9b1342d42a7
@@ -359,6 +359,7 @@ class Naver
359
359
  end
360
360
  end
361
361
  return 0
362
+ @driver.quit
362
363
  end
363
364
 
364
365
  else
@@ -382,6 +383,7 @@ class Naver
382
383
  end
383
384
  end
384
385
  return 0
386
+ @driver.quit
385
387
  end
386
388
  end
387
389
 
@@ -708,6 +710,7 @@ class Naver
708
710
  end
709
711
  end
710
712
  return 0
713
+ @driver.quit
711
714
  end
712
715
 
713
716
 
@@ -736,6 +739,7 @@ class Naver
736
739
  end
737
740
  end
738
741
  return 0
742
+ @driver.quit
739
743
  end
740
744
  sleep(2)
741
745
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -1662,6 +1666,7 @@ class Naver
1662
1666
  puts "Failed to close tab: #{e.message}"
1663
1667
  end
1664
1668
  end
1669
+ @driver.quit
1665
1670
  rescue
1666
1671
 
1667
1672
  end
@@ -2185,36 +2190,66 @@ class Wordpress
2185
2190
  puts table[10]
2186
2191
  if table[7].to_i > table[10].to_i
2187
2192
  if @data['포스트설정']['테더링'].checked?
2188
- puts 'tedering ip change...'
2189
- stdout, stderr, status = Open3.capture3('./adb devices')
2190
- if status.success?
2191
- device_id = stdout.split("\n")[1].split("\t")[0]
2192
- puts device_id
2193
- puts 'adb -s '+device_id+' shell svc data disable'
2194
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2195
- sleep(3)
2196
- puts 'adb -s '+device_id+' shell svc data enable'
2197
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2198
- sleep(3)
2199
- puts 'adb ok'
2200
- sleep(8)
2201
- robot_ip = lambda do
2202
- http = HTTP.get('https://www.findip.kr/')
2203
- noko = Nokogiri::HTML(http.to_s)
2204
- if noko.xpath('/html/body/header/h2').text != @my_ip
2205
- @my_ip = noko.xpath('/html/body/header/h2').text
2206
- else
2207
- puts @my_ip
2208
- puts '재시도...'
2209
- sleep(3)
2210
- robot_ip[]
2211
- 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초 후 재시도
2212
2238
  end
2213
- robot_ip[]
2239
+
2240
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2241
+ if retry_count >= max_retries
2242
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2243
+ end
2244
+ end
2214
2245
  else
2215
- puts 'adb error pass'
2246
+ puts 'Failed to disable data. Error: ' + stderr2
2216
2247
  end
2248
+ else
2249
+ puts 'adb error, unable to get devices. Error: ' + stderr
2250
+ end
2217
2251
  end
2252
+
2218
2253
 
2219
2254
  check_success = 1
2220
2255
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-06 00:00:00.000000000 Z
11
+ date: 2025-02-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com