Omnibus commited on
Commit
3918466
·
verified ·
1 Parent(s): 36c828e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -14,7 +14,9 @@ from selenium.webdriver.common.by import By
14
  driver_type = 'chromedriver'
15
  driver=False
16
 
17
- def get_concat_h_cut(im1, im2):
 
 
18
  dst = Image.new('RGB', (im1.width + im2.width,
19
  min(im1.height, im2.height)))
20
  dst.paste(im1, (0, 0))
@@ -33,6 +35,7 @@ def get_concat_v_cut(im1, im2):
33
 
34
  def run_script(url: str, height: int, width: int):
35
  mes_box=[]
 
36
  uid=uuid.uuid4()
37
  is_url=True
38
  if is_url:
@@ -61,6 +64,10 @@ def run_script(url: str, height: int, width: int):
61
  print (mes.text)
62
  mes.screenshot(f'{i}-{uid}-tmp.png')
63
  mes_box.append(f'{i}-{uid}-tmp.png')
 
 
 
 
64
  #obj = driver.find_element(By.ID, "app-container")
65
  #obj = driver.find_element(By.ID, "conversation-feed")
66
  #obj = driver.find_element_by_id("in_html")
@@ -84,15 +91,15 @@ def run_script(url: str, height: int, width: int):
84
  screenshot = obj.screenshot(f'{uid}-tmp.png')
85
  #screenshot = obj.get_screenshot_as_png()
86
  except WebDriverException as e:
87
- return Image.new('RGB', (1, 1)), f'<center>{e}',mes_box
88
  finally:
89
  if driver:
90
  driver.quit()
91
 
92
  #return [Image.open(BytesIO(screenshot)), 'operation success.',cookie_jar,html]
93
- return Image.open(f'{uid}-tmp.png'), '<center>operation success.',mes_box
94
  else:
95
- return None, '<center>Please enter a valid URL of a website/host.',mes_box
96
 
97
  with gr.Blocks() as app:
98
 
 
14
  driver_type = 'chromedriver'
15
  driver=False
16
 
17
+ def get_concat_h_cut(in1, in2):
18
+ im1=Image.open(in1)
19
+ im2=Image.open(in2)
20
  dst = Image.new('RGB', (im1.width + im2.width,
21
  min(im1.height, im2.height)))
22
  dst.paste(im1, (0, 0))
 
35
 
36
  def run_script(url: str, height: int, width: int):
37
  mes_box=[]
38
+ out_box=[]
39
  uid=uuid.uuid4()
40
  is_url=True
41
  if is_url:
 
64
  print (mes.text)
65
  mes.screenshot(f'{i}-{uid}-tmp.png')
66
  mes_box.append(f'{i}-{uid}-tmp.png')
67
+ if (i%2):
68
+ out_box.append(get_concat_v_cut(mes_box[0],mes_box[1]))
69
+ mes_box.clear()
70
+
71
  #obj = driver.find_element(By.ID, "app-container")
72
  #obj = driver.find_element(By.ID, "conversation-feed")
73
  #obj = driver.find_element_by_id("in_html")
 
91
  screenshot = obj.screenshot(f'{uid}-tmp.png')
92
  #screenshot = obj.get_screenshot_as_png()
93
  except WebDriverException as e:
94
+ return Image.new('RGB', (1, 1)), f'<center>{e}',out_box
95
  finally:
96
  if driver:
97
  driver.quit()
98
 
99
  #return [Image.open(BytesIO(screenshot)), 'operation success.',cookie_jar,html]
100
+ return Image.open(f'{uid}-tmp.png'), '<center>operation success.',out_box
101
  else:
102
+ return None, '<center>Please enter a valid URL of a website/host.',out_box
103
 
104
  with gr.Blocks() as app:
105