mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
Use python.exe as interpreter for .py files on windows.
This commit is contained in:
@@ -45,24 +45,13 @@ ScriptResolver::ScriptResolver( const QString& exe )
|
|||||||
connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) );
|
connect( &m_proc, SIGNAL( readyReadStandardOutput() ), SLOT( readStdout() ) );
|
||||||
connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) );
|
connect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( cmdExited( int, QProcess::ExitStatus ) ) );
|
||||||
|
|
||||||
QString runPath = filePath();
|
startProcess();
|
||||||
#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 );
|
|
||||||
|
|
||||||
if ( !TomahawkUtils::nam() )
|
if ( !TomahawkUtils::nam() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// set the name to the binary, if we launch properly we'll get the name the resolver reports
|
// set the name to the binary, if we launch properly we'll get the name the resolver reports
|
||||||
m_name = QFileInfo( filePath() ).baseName();
|
m_name = QFileInfo( filePath() ).baseName();
|
||||||
|
|
||||||
sendConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -141,15 +130,7 @@ ScriptResolver::sendConfig()
|
|||||||
void
|
void
|
||||||
ScriptResolver::reload()
|
ScriptResolver::reload()
|
||||||
{
|
{
|
||||||
if ( !QFile::exists( filePath() ) )
|
startProcess();
|
||||||
m_error = Tomahawk::ExternalResolver::FileNotFound;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_error = Tomahawk::ExternalResolver::NoError;
|
|
||||||
m_proc.start( filePath() );
|
|
||||||
|
|
||||||
sendConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -309,7 +290,7 @@ ScriptResolver::cmdExited( int code, QProcess::ExitStatus status )
|
|||||||
{
|
{
|
||||||
m_num_restarts++;
|
m_num_restarts++;
|
||||||
tLog() << "*** Restart num" << m_num_restarts;
|
tLog() << "*** Restart num" << m_num_restarts;
|
||||||
m_proc.start( filePath() );
|
startProcess();
|
||||||
sendConfig();
|
sendConfig();
|
||||||
}
|
}
|
||||||
else
|
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
|
void
|
||||||
ScriptResolver::saveConfig()
|
ScriptResolver::saveConfig()
|
||||||
{
|
{
|
||||||
|
@@ -75,6 +75,8 @@ private:
|
|||||||
void doSetup( const QVariantMap& m );
|
void doSetup( const QVariantMap& m );
|
||||||
void setupConfWidget( const QVariantMap& m );
|
void setupConfWidget( const QVariantMap& m );
|
||||||
|
|
||||||
|
void startProcess();
|
||||||
|
|
||||||
QProcess m_proc;
|
QProcess m_proc;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
|
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
|
||||||
|
Reference in New Issue
Block a user