cafe_basics 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.rb +61 -26
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de3a75f8f3ad8d9583e6cc78b40d87e20545f7be7a1a663a80b8edd2115490f5
4
- data.tar.gz: 0e56ba81d26c14152b828fee1bba01ee804a27d9fd208907d33216381dcbe4e8
3
+ metadata.gz: 6b06b45f7b30acd8084b197547c03effb6ca58ec56b11c4daeeaa98734eefc3a
4
+ data.tar.gz: 89b2277ffcc2bbc4da6b6cf45a92597103684813633801f7540d046fdd100516
5
5
  SHA512:
6
- metadata.gz: 2339dfe09a5eff4855164f81748d7019783f24ca7d082933b84a85851336829b1cbeee94511bc7825177e273298be69efe51bae166798c8fc9498e5e9b2f2bc7
7
- data.tar.gz: f731ca9880b9a38258bc337af9cb30996ef876eb206620b703e3ec37eb9468349795e6b75839f38de4d264aa6ebb5cde3c28abeffd153d2abc6431823df054e6
6
+ metadata.gz: 87e5fde891f962134677d6db010490cb16d298d9fb1523568540e56e2cd458deb09267989bcb5126c7f93362464bd60b5711e5542b887769b2ff64165b2d981b
7
+ data.tar.gz: 1c98353ff8aa441a921b0fa33d948771812b8f57f9b552b2b90bc60fa81c99636c09ae96367715b8d16454d63818d93acf21b90780038887e3d443f17c7a4c61
data/lib/cafe_basics.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
 
@@ -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
@@ -2117,36 +2122,66 @@ class Wordpress
2117
2122
  puts table[10]
2118
2123
  if table[7].to_i > table[10].to_i
2119
2124
  if @data['포스트설정']['테더링'].checked?
2120
- puts 'tedering ip change...'
2121
- stdout, stderr, status = Open3.capture3('./adb devices')
2122
- if status.success?
2123
- device_id = stdout.split("\n")[1].split("\t")[0]
2124
- puts device_id
2125
- puts 'adb -s '+device_id+' shell svc data disable'
2126
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2127
- sleep(3)
2128
- puts 'adb -s '+device_id+' shell svc data enable'
2129
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2130
- sleep(3)
2131
- puts 'adb ok'
2132
- sleep(8)
2133
- robot_ip = lambda do
2134
- http = HTTP.get('https://www.findip.kr/')
2135
- noko = Nokogiri::HTML(http.to_s)
2136
- if noko.xpath('/html/body/header/h2').text != @my_ip
2137
- @my_ip = noko.xpath('/html/body/header/h2').text
2138
- else
2139
- puts @my_ip
2140
- puts '재시도...'
2141
- sleep(3)
2142
- robot_ip[]
2143
- end
2125
+ puts 'tethering ip change...'
2126
+
2127
+ # ADB devices 확인
2128
+ stdout, stderr, status = Open3.capture3('./adb devices')
2129
+ if status.success?
2130
+ device_id = stdout.split("\n")[1].split("\t")[0]
2131
+ puts device_id
2132
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2133
+
2134
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2135
+ if status2.success?
2136
+ sleep(3)
2137
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2138
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2139
+ sleep(3)
2140
+ puts 'adb ok'
2141
+ sleep(8)
2142
+
2143
+ # IP 확인 및 재시도 (반복문 사용)
2144
+ retry_count = 0
2145
+ max_retries = 5
2146
+ current_ip = nil
2147
+
2148
+ # 무한 루프 방지
2149
+ while retry_count < max_retries
2150
+ begin
2151
+ http = HTTP.get('https://www.findip.kr/')
2152
+ noko = Nokogiri::HTML(http.to_s)
2153
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2154
+
2155
+ puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2156
+
2157
+ # IP가 변경되었으면 @my_ip를 갱신하고 종료
2158
+ if new_ip != @my_ip
2159
+ @my_ip = new_ip
2160
+ puts "IP 변경됨: #{@my_ip}"
2161
+ break
2162
+ else
2163
+ puts 'IP가 변경되지 않음. 재시도...'
2164
+ retry_count += 1
2165
+ sleep(3) # 3초 후 재시도
2166
+ end
2167
+ rescue => e
2168
+ retry_count += 1
2169
+ sleep(3) # 3초 후 재시도
2144
2170
  end
2145
- robot_ip[]
2171
+
2172
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2173
+ if retry_count >= max_retries
2174
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2175
+ end
2176
+ end
2146
2177
  else
2147
- puts 'adb error pass'
2178
+ puts 'Failed to disable data. Error: ' + stderr2
2148
2179
  end
2180
+ else
2181
+ puts 'adb error, unable to get devices. Error: ' + stderr
2182
+ end
2149
2183
  end
2184
+
2150
2185
 
2151
2186
  check_success = 1
2152
2187
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics
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