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