cafe_buy_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_buy_duo.rb +62 -27
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57342b8970b5a0d78e73b72e7c1da6a9141182f4b9953c2d55aa88c6b20243c2
4
- data.tar.gz: 95bbea5b19087d073b1fc26fdb106849d361bead41fb4f4c930c2ddacac85317
3
+ metadata.gz: d31236851bcf2d4dee34c03e6a241d00b94506fa3c4ec26eddd9c273a6d30dcb
4
+ data.tar.gz: 960b15432b170414ccf59240adf793eaed67b0587f60a93a19bf0e4813446092
5
5
  SHA512:
6
- metadata.gz: f6fb0fa920287e118243a7c015239c4a3947341907d538ea8f54e88037bef3e33f0fd6c50331f8600920f886a4237628ce588c53d149e43f6f1d0f5bd76e0a27
7
- data.tar.gz: 1b6df61e5a090430da65fee6c4fdd17ff90deb00a2512a5964b1e625974a8dcb38830c63ba6b38bdec77405b5a708154d5858c9923dcaa964ff636bffea8c74b
6
+ metadata.gz: 6422148e457afc190a2e698afda92fc73738437864427cf17717cecfab61a64b686c341dd6cc5c3c20e4bb5c8f97a67b464bcf81c2974b33a3e608c4debc1090
7
+ data.tar.gz: 61a7df43d0fd9bc65046cbfd438f01083e53ff40a5e52d6cb1430c8446ee206005a66ac895b12f0718eb5daad627961333d9384b4e1d8d9d235213eb92717103
data/lib/cafe_buy_duo.rb CHANGED
@@ -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
 
@@ -1020,7 +1022,8 @@ end
1020
1022
  puts "Failed to close tab: #{e.message}"
1021
1023
  end
1022
1024
  end
1023
- return 0
1025
+ return 0
1026
+ @driver.quit
1024
1027
  end
1025
1028
 
1026
1029
 
@@ -1049,6 +1052,7 @@ end
1049
1052
  end
1050
1053
  end
1051
1054
  return 0
1055
+ @driver.quit
1052
1056
  end
1053
1057
  sleep(2)
1054
1058
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -1970,6 +1974,7 @@ end
1970
1974
  puts "Failed to close tab: #{e.message}"
1971
1975
  end
1972
1976
  end
1977
+ @driver.quit
1973
1978
  rescue
1974
1979
 
1975
1980
  end
@@ -2515,36 +2520,66 @@ class Wordpress
2515
2520
  puts table[10]
2516
2521
  if table[7].to_i > table[10].to_i
2517
2522
  if @data['포스트설정']['테더링'].checked?
2518
- puts 'tedering ip change...'
2519
- stdout, stderr, status = Open3.capture3('./adb devices')
2520
- if status.success?
2521
- device_id = stdout.split("\n")[1].split("\t")[0]
2522
- puts device_id
2523
- puts 'adb -s '+device_id+' shell svc data disable'
2524
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2525
- sleep(3)
2526
- puts 'adb -s '+device_id+' shell svc data enable'
2527
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2528
- sleep(3)
2529
- puts 'adb ok'
2530
- sleep(8)
2531
- robot_ip = lambda do
2532
- http = HTTP.get('https://www.findip.kr/')
2533
- noko = Nokogiri::HTML(http.to_s)
2534
- if noko.xpath('/html/body/header/h2').text != @my_ip
2535
- @my_ip = noko.xpath('/html/body/header/h2').text
2536
- else
2537
- puts @my_ip
2538
- puts '재시도...'
2539
- sleep(3)
2540
- robot_ip[]
2541
- end
2523
+ puts 'tethering ip change...'
2524
+
2525
+ # ADB devices 확인
2526
+ stdout, stderr, status = Open3.capture3('./adb devices')
2527
+ if status.success?
2528
+ device_id = stdout.split("\n")[1].split("\t")[0]
2529
+ puts device_id
2530
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2531
+
2532
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2533
+ if status2.success?
2534
+ sleep(3)
2535
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2536
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2537
+ sleep(3)
2538
+ puts 'adb ok'
2539
+ sleep(8)
2540
+
2541
+ # IP 확인 및 재시도 (반복문 사용)
2542
+ retry_count = 0
2543
+ max_retries = 5
2544
+ current_ip = nil
2545
+
2546
+ # 무한 루프 방지
2547
+ while retry_count < max_retries
2548
+ begin
2549
+ http = HTTP.get('https://www.findip.kr/')
2550
+ noko = Nokogiri::HTML(http.to_s)
2551
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2552
+
2553
+ puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2554
+
2555
+ # IP가 변경되었으면 @my_ip를 갱신하고 종료
2556
+ if new_ip != @my_ip
2557
+ @my_ip = new_ip
2558
+ puts "IP 변경됨: #{@my_ip}"
2559
+ break
2560
+ else
2561
+ puts 'IP가 변경되지 않음. 재시도...'
2562
+ retry_count += 1
2563
+ sleep(3) # 3초 후 재시도
2564
+ end
2565
+ rescue => e
2566
+ retry_count += 1
2567
+ sleep(3) # 3초 후 재시도
2568
+ end
2569
+
2570
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2571
+ if retry_count >= max_retries
2572
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2542
2573
  end
2543
- robot_ip[]
2574
+ end
2544
2575
  else
2545
- puts 'adb error pass'
2576
+ puts 'Failed to disable data. Error: ' + stderr2
2546
2577
  end
2578
+ else
2579
+ puts 'adb error, unable to get devices. Error: ' + stderr
2580
+ end
2547
2581
  end
2582
+
2548
2583
 
2549
2584
  check_success = 1
2550
2585
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy_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