cafe_buy 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.rb +60 -19
- 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: e463ab640d75178f58b52d7b8d497e3be804c8c0b7bfe65fe43d6282cc50851b
|
4
|
+
data.tar.gz: b567f1e4134f93f8c7a2eaf27dba2fc5153222d9e654560db291077967c0b9ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611264125716b7d1140885b5f0eedf13eb2881498666b187a109f7f82e3083b77600529982d9acca721e551f22b07a8252359e169ab7456c6c7deb06333f881b
|
7
|
+
data.tar.gz: aea2c9ca17054b1d14d8e106481e2aae9299edc1b5baf9cf02ff1e2ddc7fb654c443226763f9040650c9ab6560b5a65558c46471c43bac6b4d9bb5eb7f3be542
|
data/lib/cafe_buy.rb
CHANGED
@@ -2452,37 +2452,78 @@ class Wordpress
|
|
2452
2452
|
puts table[10]
|
2453
2453
|
if table[7].to_i > table[10].to_i
|
2454
2454
|
if @data['포스트설정']['테더링'].checked?
|
2455
|
-
puts '
|
2455
|
+
puts 'tethering ip change...'
|
2456
|
+
|
2457
|
+
# ADB devices 확인
|
2456
2458
|
stdout, stderr, status = Open3.capture3('./adb devices')
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
|
2459
|
+
if status.success?
|
2460
|
+
device_id = stdout.split("\n")[1].split("\t")[0]
|
2461
|
+
puts device_id
|
2462
|
+
|
2463
|
+
# ADB 서버 초기화
|
2464
|
+
puts 'adb kill-server'
|
2465
|
+
Open3.capture3('adb kill-server')
|
2466
|
+
sleep(2)
|
2467
|
+
|
2468
|
+
# 다시 ADB 서버 실행
|
2469
|
+
puts 'adb start-server'
|
2470
|
+
Open3.capture3('adb start-server')
|
2471
|
+
sleep(2)
|
2472
|
+
|
2473
|
+
# 데이터를 끄고 켜기
|
2474
|
+
puts 'adb -s ' + device_id + ' shell svc data disable'
|
2475
|
+
stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
|
2476
|
+
|
2477
|
+
if status2.success?
|
2462
2478
|
sleep(3)
|
2463
|
-
puts 'adb -s '+device_id+' shell svc data enable'
|
2464
|
-
Open3.capture3('./adb -s '+device_id+' shell svc data enable')
|
2479
|
+
puts 'adb -s ' + device_id + ' shell svc data enable'
|
2480
|
+
Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
|
2465
2481
|
sleep(3)
|
2466
2482
|
puts 'adb ok'
|
2467
2483
|
sleep(8)
|
2468
|
-
|
2484
|
+
|
2485
|
+
# IP 확인 및 재시도 (반복문 사용)
|
2486
|
+
retry_count = 0
|
2487
|
+
max_retries = 5
|
2488
|
+
current_ip = nil
|
2489
|
+
|
2490
|
+
# 무한 루프 방지
|
2491
|
+
while retry_count < max_retries
|
2492
|
+
begin
|
2469
2493
|
http = HTTP.get('https://www.findip.kr/')
|
2470
2494
|
noko = Nokogiri::HTML(http.to_s)
|
2471
|
-
|
2472
|
-
|
2495
|
+
new_ip = noko.xpath('/html/body/header/h2').text.strip
|
2496
|
+
|
2497
|
+
puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
|
2498
|
+
|
2499
|
+
# IP가 변경되었으면 @my_ip를 갱신하고 종료
|
2500
|
+
if new_ip != @my_ip
|
2501
|
+
@my_ip = new_ip
|
2502
|
+
puts "IP 변경됨: #{@my_ip}"
|
2503
|
+
break
|
2473
2504
|
else
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
robot_ip[]
|
2505
|
+
puts 'IP가 변경되지 않음. 재시도...'
|
2506
|
+
retry_count += 1
|
2507
|
+
sleep(3) # 3초 후 재시도
|
2478
2508
|
end
|
2509
|
+
rescue => e
|
2510
|
+
retry_count += 1
|
2511
|
+
sleep(3) # 3초 후 재시도
|
2512
|
+
end
|
2513
|
+
|
2514
|
+
# 최대 재시도 횟수를 초과하면 예외 발생시키기
|
2515
|
+
if retry_count >= max_retries
|
2516
|
+
raise "최대 재시도 횟수 초과. IP 변경 실패."
|
2517
|
+
end
|
2479
2518
|
end
|
2480
|
-
|
2519
|
+
else
|
2520
|
+
puts 'Failed to disable data. Error: ' + stderr2
|
2521
|
+
end
|
2481
2522
|
else
|
2482
|
-
|
2523
|
+
puts 'adb error, unable to get devices. Error: ' + stderr
|
2483
2524
|
end
|
2484
|
-
|
2485
|
-
|
2525
|
+
end
|
2526
|
+
|
2486
2527
|
check_success = 1
|
2487
2528
|
@data['table'][index][-1] = 0
|
2488
2529
|
if @data['제목설정']['제목'].length == 0
|