1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 23:39:42 +01:00

Use python.exe as interpreter for .py files on windows.

This commit is contained in:
Dominik Schmidt 2011-12-26 20:14:42 +01:00
parent 4c8fa37d0e
commit 9a13d475a6
2 changed files with 40 additions and 22 deletions

View File

@ -45,24 +45,13 @@ ScriptResolver::ScriptResolver( const QString& exe )
connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) );
connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) );
QString runPath = filePath();
#ifdef WIN32
// have to enclose in quotes if path contains spaces on windows...
runPath = QString( "\"%1\"" ).arg( filePath() );
#endif
if ( !QFile::exists( filePath() ) )
m_error = Tomahawk::ExternalResolver::FileNotFound;
else
m_proc.start( runPath );
startProcess();
if ( !TomahawkUtils::nam() )
return;
// set the name to the binary, if we launch properly we'll get the name the resolver reports
m_name = QFileInfo( filePath() ).baseName();
sendConfig();
}
@ -141,15 +130,7 @@ ScriptResolver::sendConfig()
void
ScriptResolver::reload()
{
if ( !QFile::exists( filePath() ) )
m_error = Tomahawk::ExternalResolver::FileNotFound;
else
{
m_error = Tomahawk::ExternalResolver::NoError;
m_proc.start( filePath() );
sendConfig();
}
startProcess();
}
@ -309,7 +290,7 @@ ScriptResolver::cmdExited( int code, QProcess::ExitStatus status )
{
m_num_restarts++;
tLog() << "*** Restart num" << m_num_restarts;
m_proc.start( filePath() );
startProcess();
sendConfig();
}
else
@ -381,6 +362,41 @@ ScriptResolver::setupConfWidget( const QVariantMap& m )
}
void ScriptResolver::startProcess()
{
if ( !QFile::exists( filePath() ) )
m_error = Tomahawk::ExternalResolver::FileNotFound;
else
{
m_error = Tomahawk::ExternalResolver::NoError;
}
QFileInfo fi( filePath() );
QString interpreter;
QString runPath = filePath();
#ifdef Q_OS_WIN
if(fi.completeSuffix() == "py")
{
interpreter = "python.exe";
}
else
{
// have to enclose in quotes if path contains spaces on windows...
runPath = QString( "\"%1\"" ).arg( filePath() );
}
#endif // Q_OS_WIN
if( interpreter.isEmpty() )
m_proc.start( runPath );
else
m_proc.start( interpreter, QStringList() << filePath() );
sendConfig();
}
void
ScriptResolver::saveConfig()
{

View File

@ -75,6 +75,8 @@ private:
void doSetup( const QVariantMap& m );
void setupConfWidget( const QVariantMap& m );
void startProcess();
QProcess m_proc;
QString m_name;
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;