mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-19 06:03:59 +00:00
Remove picard.browser.launch
This commit is contained in:
@@ -52,14 +52,13 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
import os.path
|
||||
import urllib
|
||||
from os.path import basename
|
||||
import launch
|
||||
from picard.util import webbrowser2
|
||||
|
||||
class FileLookup(object):
|
||||
|
||||
class FileLookup(launch.Launch):
|
||||
|
||||
def __init__(self, parent, server, port, localPort):
|
||||
launch.Launch.__init__(self, parent)
|
||||
self.server = server
|
||||
self.localPort = int(localPort)
|
||||
self.port = port
|
||||
@@ -67,6 +66,9 @@ class FileLookup(launch.Launch):
|
||||
def _encode(self, text):
|
||||
return urllib.quote(text.encode('UTF-8', 'replace'))
|
||||
|
||||
def launch(self, url):
|
||||
webbrowser2.open(url)
|
||||
|
||||
def discLookup(self, url):
|
||||
return self.launch("%s&tport=%d" % (url, self.localPort))
|
||||
|
||||
@@ -116,6 +118,6 @@ class FileLookup(launch.Launch):
|
||||
self._encode(track),
|
||||
trackNum,
|
||||
duration,
|
||||
self._encode(basename(filename)),
|
||||
self._encode(os.path.basename(filename)),
|
||||
self._encode(puid))
|
||||
return self.launch(url)
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: RCSL 1.0/RPSL 1.0/GPL 2.0
|
||||
#
|
||||
# Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
|
||||
# Portions Copyright (c) 2004 Robert Kaye. All Rights Reserved.
|
||||
#
|
||||
# The contents of this file, and the files included with this file, are
|
||||
# subject to the current version of the RealNetworks Public Source License
|
||||
# Version 1.0 (the "RPSL") available at
|
||||
# http://www.helixcommunity.org/content/rpsl unless you have licensed
|
||||
# the file under the RealNetworks Community Source License Version 1.0
|
||||
# (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
|
||||
# in which case the RCSL will apply. You may also obtain the license terms
|
||||
# directly from RealNetworks. You may not use this file except in
|
||||
# compliance with the RPSL or, if you have a valid RCSL with RealNetworks
|
||||
# applicable to this file, the RCSL. Please see the applicable RPSL or
|
||||
# RCSL for the rights, obligations and limitations governing use of the
|
||||
# contents of the file.
|
||||
#
|
||||
# This file is part of the Helix DNA Technology. RealNetworks is the
|
||||
# developer of the Original Code and owns the copyrights in the portions
|
||||
# it created.
|
||||
#
|
||||
# This file, and the files included with this file, is distributed and made
|
||||
# available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
# EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
#
|
||||
# Technology Compatibility Kit Test Suite(s) Location:
|
||||
# http://www.helixcommunity.org/content/tck
|
||||
#
|
||||
# --------------------------------------------------------------------
|
||||
#
|
||||
# picard is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# picard is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with picard; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# Contributor(s):
|
||||
# Robert Kaye
|
||||
# Lukas Lalinsky
|
||||
#
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
import sys
|
||||
import os
|
||||
import webbrowser
|
||||
import tempfile
|
||||
|
||||
# KDE default browser
|
||||
if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'):
|
||||
webbrowser.register('kfmclient', None, webbrowser.GenericBrowser("kfmclient exec '%s' &"))
|
||||
if 'BROWSER' in os.environ:
|
||||
webbrowser._tryorder.insert(len(os.environ['BROWSER'].split(os.pathsep)), 'kfmclient')
|
||||
else:
|
||||
webbrowser._tryorder.insert(0, 'kfmclient')
|
||||
|
||||
# GNOME default browser
|
||||
if 'GNOME_DESKTOP_SESSION_ID' in os.environ and webbrowser._iscommand('gnome-open'):
|
||||
webbrowser.register('gnome-open', None, webbrowser.GenericBrowser("gnome-open '%s' &"))
|
||||
if 'BROWSER' in os.environ:
|
||||
webbrowser._tryorder.insert(len(os.environ['BROWSER'].split(os.pathsep)), 'gnome-open')
|
||||
else:
|
||||
webbrowser._tryorder.insert(0, 'gnome-open')
|
||||
|
||||
class Launch(object):
|
||||
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
|
||||
def getTempFile(self):
|
||||
tempDir = tempfile.gettempdir()
|
||||
return wpath.wpath().join(tempDir, "post.html")
|
||||
|
||||
def cleanup(self):
|
||||
try:
|
||||
os.unlink(self.getTempFile())
|
||||
except:
|
||||
pass
|
||||
|
||||
def launch(self, url):
|
||||
# If the browser var does not specify the %s, warn the user
|
||||
browser = os.environ.get('BROWSER')
|
||||
if browser and browser not in webbrowser._browsers and ('%s' not in browser or '&' not in browser):
|
||||
dlg = wx.MessageDialog(self.parent, "Your BROWSER variable does not contain a %s and/or a & ."+
|
||||
" To ensure that your browser launches correctly and doesn't lock the rest of the "+
|
||||
" application, make sure your BROWSER environment varable includes a %s &. For example, "+
|
||||
' BROWSER="firefox \'%s\' &" should work to launch Firefox correctly.', style=wx.OK)
|
||||
dlg.ShowModal()
|
||||
|
||||
try:
|
||||
webbrowser.open(url)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def post(self, post):
|
||||
try:
|
||||
file = open(self.getTempFile(), "w")
|
||||
file.write(post);
|
||||
file.close()
|
||||
except IOError:
|
||||
dlg = wx.MessageDialog(self.parent, "Could not write a temporary file to launch a browser.",
|
||||
"HTTP POST Launch", style=wx.OK)
|
||||
dlg.ShowModal()
|
||||
|
||||
self.launch("file://" + self.getTempFile())
|
||||
@@ -18,6 +18,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from picard.util import webbrowser2
|
||||
|
||||
|
||||
# Amazon associate and developer ids
|
||||
@@ -111,10 +112,9 @@ class CoverArtBox(QtGui.QGroupBox):
|
||||
self.asin = asin
|
||||
|
||||
def open_amazon(self):
|
||||
from picard.browser.launch import Launch
|
||||
# TODO: make this configurable
|
||||
store = "amazon.com"
|
||||
url = "http://%s/exec/obidos/ASIN/%s/%s?v=glance&s=music" % (
|
||||
store, self.asin, _amazon_store_associate_ids[store])
|
||||
Launch(None).launch(url)
|
||||
webbrowser2.open(url)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ from picard.ui.metadatabox import MetadataBox
|
||||
from picard.ui.filebrowser import FileBrowser
|
||||
from picard.ui.options import OptionsDialogProvider
|
||||
from picard.ui.tageditor import TagEditor
|
||||
from picard.util import icontheme
|
||||
from picard.util import icontheme, webbrowser2
|
||||
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
@@ -402,8 +402,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
dlg.exec_()
|
||||
|
||||
def show_help(self):
|
||||
from picard.browser.launch import Launch
|
||||
Launch(None).launch("http://musicbrainz.org/doc/PicardDocumentation")
|
||||
webbrowser2.open("http://musicbrainz.org/doc/PicardDocumentation")
|
||||
|
||||
def save(self):
|
||||
"""Tell the tagger to save the selected objects."""
|
||||
|
||||
@@ -21,6 +21,7 @@ from PyQt4 import QtCore, QtGui
|
||||
from picard.api import IOptionsPage
|
||||
from picard.component import Component, ExtensionPoint
|
||||
from picard.config import Option
|
||||
from picard.util import webbrowser2
|
||||
from picard.ui.options import (
|
||||
about,
|
||||
advanced,
|
||||
@@ -110,8 +111,7 @@ class OptionsDialog(QtGui.QDialog):
|
||||
self.ui.pages_stack.setCurrentWidget(page)
|
||||
|
||||
def help(self):
|
||||
# FIXME
|
||||
self.log.info('HELP!')
|
||||
webbrowser2.open('http://musicbrainz.org/doc/PicardDocumentation/Options')
|
||||
|
||||
def accept(self):
|
||||
for page in self.pages:
|
||||
|
||||
39
picard/util/webbrowser2.py
Normal file
39
picard/util/webbrowser2.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Picard, the next-generation MusicBrainz tagger
|
||||
# Copyright (C) 2006 Lukáš Lalinský
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
import os
|
||||
import webbrowser
|
||||
|
||||
# KDE default browser
|
||||
if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'):
|
||||
webbrowser.register('kfmclient', None, webbrowser.GenericBrowser("kfmclient exec '%s' &"))
|
||||
if 'BROWSER' in os.environ:
|
||||
webbrowser._tryorder.insert(len(os.environ['BROWSER'].split(os.pathsep)), 'kfmclient')
|
||||
else:
|
||||
webbrowser._tryorder.insert(0, 'kfmclient')
|
||||
|
||||
# GNOME default browser
|
||||
if 'GNOME_DESKTOP_SESSION_ID' in os.environ and webbrowser._iscommand('gnome-open'):
|
||||
webbrowser.register('gnome-open', None, webbrowser.GenericBrowser("gnome-open '%s' &"))
|
||||
if 'BROWSER' in os.environ:
|
||||
webbrowser._tryorder.insert(len(os.environ['BROWSER'].split(os.pathsep)), 'gnome-open')
|
||||
else:
|
||||
webbrowser._tryorder.insert(0, 'gnome-open')
|
||||
|
||||
open = webbrowser.open
|
||||
Reference in New Issue
Block a user