cafe_buy_duo 0.0.37 → 0.0.50
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 +4 -4
- data/lib/cafe_buy_duo.rb +60 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83fb173eb310d5333ab8c67ccf1a5e950094f5bab2d5bc3fff9e80d5b81b9f06
|
4
|
+
data.tar.gz: 96763301bb9dc3d2d4711fc251bdc7d210fd4175d659425eb2931c3723f5347f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a15ee5df00caa27fffd25422e526ae8b1a6e81bd5795771763640acdc63e2e046bbb366048e217e945e49c70c56e6cdd24e4abfa124b8a978811051a578e78a
|
7
|
+
data.tar.gz: '089f3bc6d90127a74693647c4205c3149618f33c321629cbeeb3a76edb00e5678fd7ba09a5d8cdee6dc20350bb69fe3f498674f8e233b19b27291c875f10d8c8'
|
data/lib/cafe_buy_duo.rb
CHANGED
@@ -2520,36 +2520,78 @@ class Wordpress
|
|
2520
2520
|
puts table[10]
|
2521
2521
|
if table[7].to_i > table[10].to_i
|
2522
2522
|
if @data['포스트설정']['테더링'].checked?
|
2523
|
-
puts '
|
2523
|
+
puts 'tethering ip change...'
|
2524
|
+
|
2525
|
+
# ADB devices 확인
|
2524
2526
|
stdout, stderr, status = Open3.capture3('./adb devices')
|
2525
|
-
|
2526
|
-
|
2527
|
-
|
2528
|
-
|
2529
|
-
|
2527
|
+
if status.success?
|
2528
|
+
device_id = stdout.split("\n")[1].split("\t")[0]
|
2529
|
+
puts device_id
|
2530
|
+
|
2531
|
+
# ADB 서버 초기화
|
2532
|
+
puts 'adb kill-server'
|
2533
|
+
Open3.capture3('adb kill-server')
|
2534
|
+
sleep(2)
|
2535
|
+
|
2536
|
+
# 다시 ADB 서버 실행
|
2537
|
+
puts 'adb start-server'
|
2538
|
+
Open3.capture3('adb start-server')
|
2539
|
+
sleep(2)
|
2540
|
+
|
2541
|
+
# 데이터를 끄고 켜기
|
2542
|
+
puts 'adb -s ' + device_id + ' shell svc data disable'
|
2543
|
+
stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
|
2544
|
+
|
2545
|
+
if status2.success?
|
2530
2546
|
sleep(3)
|
2531
|
-
puts 'adb -s '+device_id+' shell svc data enable'
|
2532
|
-
Open3.capture3('./adb -s '+device_id+' shell svc data enable')
|
2547
|
+
puts 'adb -s ' + device_id + ' shell svc data enable'
|
2548
|
+
Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
|
2533
2549
|
sleep(3)
|
2534
2550
|
puts 'adb ok'
|
2535
2551
|
sleep(8)
|
2536
|
-
|
2552
|
+
|
2553
|
+
# IP 확인 및 재시도 (반복문 사용)
|
2554
|
+
retry_count = 0
|
2555
|
+
max_retries = 5
|
2556
|
+
current_ip = nil
|
2557
|
+
|
2558
|
+
# 무한 루프 방지
|
2559
|
+
while retry_count < max_retries
|
2560
|
+
begin
|
2537
2561
|
http = HTTP.get('https://www.findip.kr/')
|
2538
2562
|
noko = Nokogiri::HTML(http.to_s)
|
2539
|
-
|
2540
|
-
|
2563
|
+
new_ip = noko.xpath('/html/body/header/h2').text.strip
|
2564
|
+
|
2565
|
+
puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
|
2566
|
+
|
2567
|
+
# IP가 변경되었으면 @my_ip를 갱신하고 종료
|
2568
|
+
if new_ip != @my_ip
|
2569
|
+
@my_ip = new_ip
|
2570
|
+
puts "IP 변경됨: #{@my_ip}"
|
2571
|
+
break
|
2541
2572
|
else
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
robot_ip[]
|
2573
|
+
puts 'IP가 변경되지 않음. 재시도...'
|
2574
|
+
retry_count += 1
|
2575
|
+
sleep(3) # 3초 후 재시도
|
2546
2576
|
end
|
2577
|
+
rescue => e
|
2578
|
+
retry_count += 1
|
2579
|
+
sleep(3) # 3초 후 재시도
|
2580
|
+
end
|
2581
|
+
|
2582
|
+
# 최대 재시도 횟수를 초과하면 예외 발생시키기
|
2583
|
+
if retry_count >= max_retries
|
2584
|
+
raise "최대 재시도 횟수 초과. IP 변경 실패."
|
2585
|
+
end
|
2547
2586
|
end
|
2548
|
-
|
2587
|
+
else
|
2588
|
+
puts 'Failed to disable data. Error: ' + stderr2
|
2589
|
+
end
|
2549
2590
|
else
|
2550
|
-
|
2591
|
+
puts 'adb error, unable to get devices. Error: ' + stderr
|
2551
2592
|
end
|
2552
|
-
|
2593
|
+
end
|
2594
|
+
|
2553
2595
|
|
2554
2596
|
check_success = 1
|
2555
2597
|
@data['table'][index][-1] = 0
|