13
13
# limitations under the License.
14
14
15
15
import asyncio
16
- import gzip
17
- import os
18
- import shutil
19
- import stat
20
16
import subprocess
21
17
import sys
22
18
from typing import Any
25
21
26
22
from playwright .async_api import Playwright as AsyncPlaywright
27
23
from playwright .connection import Connection
28
- from playwright .helper import Error , not_installed_error
24
+ from playwright .helper import Error
29
25
from playwright .object_factory import create_remote_object
30
26
from playwright .path_utils import get_file_dirname
31
27
from playwright .playwright import Playwright
@@ -47,15 +43,7 @@ def compute_driver_name() -> str:
47
43
async def run_driver_async () -> Connection :
48
44
package_path = get_file_dirname ()
49
45
driver_name = compute_driver_name ()
50
- driver_executable = package_path / driver_name
51
- archive_name = package_path / "drivers" / (driver_name + ".gz" )
52
-
53
- if not driver_executable .exists () or os .path .getmtime (
54
- driver_executable
55
- ) < os .path .getmtime (archive_name ):
56
- raise not_installed_error (
57
- "Playwright requires additional post-installation step to be made."
58
- )
46
+ driver_executable = package_path / "drivers" / driver_name
59
47
60
48
proc = await asyncio .create_subprocess_exec (
61
49
str (driver_executable ),
@@ -127,24 +115,8 @@ def main() -> None:
127
115
return
128
116
package_path = get_file_dirname ()
129
117
driver_name = compute_driver_name ()
130
- driver_executable = package_path / driver_name
131
- archive_name = package_path / "drivers" / (driver_name + ".gz" )
132
-
133
- if not driver_executable .exists () or os .path .getmtime (
134
- driver_executable
135
- ) < os .path .getmtime (archive_name ):
136
- print (f"Extracting { archive_name } into { driver_executable } ..." )
137
- with gzip .open (archive_name , "rb" ) as f_in , open (
138
- driver_executable , "wb"
139
- ) as f_out :
140
- shutil .copyfileobj (f_in , f_out )
141
-
142
- st = os .stat (driver_executable )
143
- if st .st_mode & stat .S_IEXEC == 0 :
144
- print (f"Making { driver_executable } executable..." )
145
- os .chmod (driver_executable , st .st_mode | stat .S_IEXEC )
146
-
118
+ driver_executable = package_path / "drivers" / driver_name
147
119
print ("Installing the browsers..." )
148
- subprocess .run (f"{ driver_executable } install" , shell = True )
120
+ subprocess .check_call (f"{ driver_executable } install" , shell = True )
149
121
150
122
print ("Playwright is now ready for use" )
0 commit comments