Wei Cheng Pan avatar Wei Cheng Pan committed 3139303

Tiny fix.

Comments (0)

Files changed (3)

Krapture/server/src/Sikuli/SikuliClient.cpp

 client( new QProcess( this ) ),
 engine( new QScriptEngine( this ) ),
 sio( this->server ),
-timer( new QTimer( this ) ),
 clientPath(),
 clientWD(),
 bundles(),
 	this->connect( this->server, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( onFinished( int, QProcess::ExitStatus ) ) );
 
 	this->sio.setCodec( QTextCodec::codecForName( "UTF-8" ) );
-
-	/*
-	This timer was designed for check each operation's timeout.
-	But since we don't know each script's execution time, this timer is not used.
-	*/
-	this->connect( this->timer, SIGNAL( timeout() ), SLOT( onTimeout() ) );
-	this->timer->setInterval( 30 * 1000 );
-	this->timer->setSingleShot( true );
 }
 
 void SikuliClient::Private::onActionTimeout( const QString & message ) {
 	this->client->kill();
 	// TODO asynchronous if need
 	this->client->waitForFinished();
-	this->timer->stop();
 	this->doSuccess = nullptr;
 	this->doFailure = nullptr;
 
 }
 
 void SikuliClient::Private::readCapture() {
-	this->timer->stop();
 	this->doSuccess = nullptr;
 	this->doFailure = nullptr;
 
 
 		auto result = data.value( "result" ).toString();
 		if( result == "succeed" ) {
-			emit this->executed( true, "" );
-
 			this->client->kill();
-//			this->timer->stop();
 			this->doSuccess = nullptr;
 			this->doFailure = nullptr;
-
+			
+			emit this->executed( true, "" );
 			return;
 		} else if( result == "failed" ) {
-			emit this->executed( false, data.value( "message" ).toString() );
-
 			this->client->kill();
-//			this->timer->stop();
 			this->doSuccess = nullptr;
 			this->doFailure = nullptr;
-
+			
+			emit this->executed( false, data.value( "message" ).toString() );
 			return;
 		} else if( result == "input" ) {
 			auto id = data.value( "id" ).toInt();
 }
 
 void SikuliClient::Private::readReadyToken() {
-	this->timer->stop();
-
 	bool ready = false;
 	while( !this->sio.atEnd() ) {
 		QString line( this->sio.readLine() );
 		emit this->ready();
 		return;
 	}
-	this->timer->start();
 }
 
 void SikuliClient::Private::nextBundle() {
 	args.setProperty( "path", getBundlePath( std::get< 0 >( bundle ) ) );
 
 	this->sio << this->encode( args ) << endl;
-	this->timer->start();
 }
 
 QVariantMap SikuliClient::Private::decode( const QString & base64 ) {
 	args.append( path );
 	args.append( "--quite" );
 	this->p_->server->start( "java", args );
-//	this->p_->timer->start();
 	this->p_->opening = true;
 }
 
 	args.setProperty( "command", "capture" );
 
 	this->p_->sio << this->p_->encode( args ) << endl;
-//	this->p_->timer->start();
 }
 
 void SikuliClient::execute( const QString & script, const QString & programOptions ) {
 	args.setProperty( "script", script );
 
 	this->p_->sio << this->p_->encode( args ) << endl;
-//	this->p_->timer->start();
 }
 
 void SikuliClient::executeBundles( const std::vector< std::tuple< QString, QString > > & bundles ) {

Krapture/server/src/Sikuli/SikuliClient_p.hpp

 	QVariantMap decode( const QString & );
 	QString encode( const QScriptValue & );
 
-	Command doFailure;
-	Command doSuccess;
-	bool opening;
-	QProcess * server;
-	QProcess * client;
-	QScriptEngine * engine;
-	QTextStream sio;
-	QTimer * timer;
-	QString clientPath;
-	QString clientWD;
-	BundleList bundles;
-	BundleList::size_type currentBundle;
-
 public slots:
 	void onFinished( int, QProcess::ExitStatus );
 	void onReadyRead();
 	void log( const QString & );
 	void ready();
 	void taskCompleted( const QString &, bool, const QString & );
+
+public:
+	Command doFailure;
+	Command doSuccess;
+	bool opening;
+	QProcess * server;
+	QProcess * client;
+	QScriptEngine * engine;
+	QTextStream sio;
+	QString clientPath;
+	QString clientWD;
+	BundleList bundles;
+	BundleList::size_type currentBundle;
 };
 
 }

SikuliServer/src/edu/ncu/csie/oolab/CommandParser.java

 		this.python_.exec( "from sikuli.Sikuli import *" );
 		this.python_.exec( "def spyInput(id_, delay, object_, method, *args):\n    from edu.ncu.csie.oolab import CommandParser\n    CommandParser.input(id_, delay, object_, method, args)\n" );
 		this.python_.exec( "def spyCheck():\n    from edu.ncu.csie.oolab import CommandParser\n    CommandParser.check()\n" );
-		this.python_.exec( "spyInput(0, 0, 'object', 'method', 0, 0.5, True, 'str')" );
 	}
 
 	/**
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.