Class for all browsers started with a command and without remote functionality.
| 166 | |
| 167 | |
| 168 | class GenericBrowser(BaseBrowser): |
| 169 | """Class for all browsers started with a command |
| 170 | and without remote functionality.""" |
| 171 | |
| 172 | def __init__(self, name): |
| 173 | if isinstance(name, str): |
| 174 | self.name = name |
| 175 | self.args = ["%s"] |
| 176 | else: |
| 177 | # name should be a list with arguments |
| 178 | self.name = name[0] |
| 179 | self.args = name[1:] |
| 180 | self.basename = os.path.basename(self.name) |
| 181 | |
| 182 | def open(self, url, new=0, autoraise=True): |
| 183 | sys.audit("webbrowser.open", url) |
| 184 | cmdline = [self.name] + [arg.replace("%s", url) |
| 185 | for arg in self.args] |
| 186 | try: |
| 187 | if sys.platform[:3] == 'win': |
| 188 | p = subprocess.Popen(cmdline) |
| 189 | else: |
| 190 | p = subprocess.Popen(cmdline, close_fds=True) |
| 191 | return not p.wait() |
| 192 | except OSError: |
| 193 | return False |
| 194 | |
| 195 | |
| 196 | class BackgroundBrowser(GenericBrowser): |
no outgoing calls
no test coverage detected