@@ -495,132 +495,30 @@ def register_X_browsers():
495
495
#
496
496
497
497
if sys .platform [:3 ] == "win" :
498
-
499
498
class WindowsDefault (BaseBrowser ):
500
- # Windows Default opening arguments.
501
-
502
- cmd = "start"
503
- newwindow = ""
504
- newtab = ""
505
-
506
499
def open (self , url , new = 0 , autoraise = True ):
507
- # Format the command for optional arguments and add the url.
508
- if new == 1 :
509
- self .cmd += " " + self .newwindow
510
- elif new == 2 :
511
- self .cmd += " " + self .newtab
512
- self .cmd += " " + url
513
500
try :
514
- subprocess . call ( self . cmd , shell = True )
501
+ os . startfile ( url )
515
502
except OSError :
516
503
# [Error 22] No application is associated with the specified
517
504
# file for this operation: '<URL>'
518
505
return False
519
506
else :
520
507
return True
521
508
522
-
523
- # Windows Sub-Classes for commonly used browsers.
524
-
525
- class InternetExplorer (WindowsDefault ):
526
- """Launcher class for Internet Explorer browser"""
527
-
528
- cmd = "start iexplore.exe"
529
- newwindow = ""
530
- newtab = ""
531
-
532
-
533
- class WinChrome (WindowsDefault ):
534
- """Launcher class for windows specific Google Chrome browser"""
535
-
536
- cmd = "start chrome.exe"
537
- newwindow = "-new-window"
538
- newtab = "-new-tab"
539
-
540
-
541
- class WinFirefox (WindowsDefault ):
542
- """Launcher class for windows specific Firefox browser"""
543
-
544
- cmd = "start firefox.exe"
545
- newwindow = "-new-window"
546
- newtab = "-new-tab"
547
-
548
-
549
- class WinOpera (WindowsDefault ):
550
- """Launcher class for windows specific Opera browser"""
551
-
552
- cmd = "start opera"
553
- newwindow = ""
554
- newtab = ""
555
-
556
-
557
- class WinSeaMonkey (WindowsDefault ):
558
- """Launcher class for windows specific SeaMonkey browser"""
559
-
560
- cmd = "start seamonkey"
561
- newwinow = ""
562
- newtab = ""
563
-
564
-
565
509
_tryorder = []
566
510
_browsers = {}
567
511
568
- # First try to use the default Windows browser.
512
+ # First try to use the default Windows browser
569
513
register ("windows-default" , WindowsDefault )
570
514
571
- def find_windows_browsers ():
572
- """ Access the windows registry to determine
573
- what browsers are on the system.
574
- """
575
-
576
- import winreg
577
- HKLM = winreg .HKEY_LOCAL_MACHINE
578
- subkey = r'Software\Clients\StartMenuInternet'
579
- read32 = winreg .KEY_READ | winreg .KEY_WOW64_32KEY
580
- read64 = winreg .KEY_READ | winreg .KEY_WOW64_64KEY
581
- key32 = winreg .OpenKey (HKLM , subkey , access = read32 )
582
- key64 = winreg .OpenKey (HKLM , subkey , access = read64 )
583
-
584
- # Return a list of browsers found in the registry
585
- # Check if there are any different browsers in the
586
- # 32 bit location instead of the 64 bit location.
587
- browsers = []
588
- i = 0
589
- while True :
590
- try :
591
- browsers .append (winreg .EnumKey (key32 , i ))
592
- except EnvironmentError :
593
- break
594
- i += 1
595
-
596
- i = 0
597
- while True :
598
- try :
599
- browsers .append (winreg .EnumKey (key64 , i ))
600
- except EnvironmentError :
601
- break
602
- i += 1
603
-
604
- winreg .CloseKey (key32 )
605
- winreg .CloseKey (key64 )
606
-
607
- return browsers
608
-
609
- # Detect some common windows browsers
610
- for browser in find_windows_browsers ():
611
- browser = browser .lower ()
612
- if "iexplore" in browser :
613
- register ("iexplore" , None , InternetExplorer ("iexplore" ))
614
- elif "chrome" in browser :
615
- register ("chrome" , None , WinChrome ("chrome" ))
616
- elif "firefox" in browser :
617
- register ("firefox" , None , WinFirefox ("firefox" ))
618
- elif "opera" in browser :
619
- register ("opera" , None , WinOpera ("opera" ))
620
- elif "seamonkey" in browser :
621
- register ("seamonkey" , None , WinSeaMonkey ("seamonkey" ))
622
- else :
623
- register (browser , None , WindowsDefault (browser ))
515
+ # Detect some common Windows browsers, fallback to IE
516
+ iexplore = os .path .join (os .environ .get ("PROGRAMFILES" , "C:\\ Program Files" ),
517
+ "Internet Explorer\\ IEXPLORE.EXE" )
518
+ for browser in ("firefox" , "firebird" , "seamonkey" , "mozilla" ,
519
+ "netscape" , "opera" , iexplore ):
520
+ if shutil .which (browser ):
521
+ register (browser , None , BackgroundBrowser (browser ))
624
522
625
523
#
626
524
# Platform support for MacOS
0 commit comments