PythonWrapper::PythonWrapper() { Py_Initialize(); PyEval_InitThreads(); globals_ = bp::import(MAIN_MODULE).attr(DICT_ATTR); mainThreadState_ = PyEval_SaveThread(); execFile(":/Python/Twitch", false); execFile(":/Python/IRCParser", false); qAddPostRoutine(clean); }
bool Terminal::execute(QStringList args) { // TODO // if(args.count() == NO_ARGUMENTS_COUNT) { // execInteractiveInstance(); // return true; // } for(int i = 1; i < args.count(); i++) { std::string str = args[i].toLocal8Bit().constData(); if(str == "--file" || str == "-f") { if(args.count() == i+1) { std::cout << "Please specify the file..." << std::endl; m_appReturn = -1; return false; } bool result = execFile(args[i+1]); return result; } if(str == "--version" || str == "-v") { execVersion(); return false; } if(str == "--help" || str == "-h") { execHelp(); return false; } } std::cout << "JsWebScrape: invalid option." << std::endl; std::cout << "Try './JsWebScrape --help' for more information." << std::endl; return false; }
bool Scope::execFile( const string& filename , bool printResult , bool reportError , bool assertOnError, int timeoutMs ){ path p( filename ); if ( ! exists( p ) ){ log() << "file [" << filename << "] doesn't exist" << endl; if ( assertOnError ) assert( 0 ); return false; } // iterate directories and recurse using all *.js files in the directory if ( is_directory( p ) ){ directory_iterator end; bool empty = true; for (directory_iterator it (p); it != end; it++){ empty = false; path sub (*it); if (!endsWith(sub.string().c_str(), ".js")) continue; if (!execFile(sub.string().c_str(), printResult, reportError, assertOnError, timeoutMs)) return false; } if (empty){ log() << "directory [" << filename << "] doesn't have any *.js files" << endl; if ( assertOnError ) assert( 0 ); return false; } return true; } File f; f.open( filename.c_str() , true ); unsigned L; { fileofs fo = f.len(); assert( fo <= 0x7ffffffe ); L = (unsigned) fo; } boost::scoped_array<char> data (new char[L+1]); data[L] = 0; f.read( 0 , data.get() , L ); int offset = 0; if (data[0] == '#' && data[1] == '!'){ const char* newline = strchr(data.get(), '\n'); if (! newline) return true; // file of just shebang treated same as empty file offset = newline - data.get(); } StringData code (data.get() + offset, L - offset); return exec( code , filename , printResult , reportError , assertOnError, timeoutMs ); }
int TestMain::invokeSoftwareRenderTest(std::string test) { mConfig.setValue("opengl", 0); mConfig.write(); int ret = execFile(fileName, fileName, "-t", test, 30); log->log("%s: %d", test.c_str(), ret); return ret; }
int TestMain::invokeTest(std::string test) { mConfig.setValue("opengl", 0); mConfig.write(); int ret = execFile(fileName, fileName, "-t", test); return ret; }
bool Scope::execFile(const string& filename, bool printResult, bool reportError, int timeoutMs) { #ifdef _WIN32 boost::filesystem::path p(toWideString(filename.c_str())); #else boost::filesystem::path p(filename); #endif if (!exists(p)) { log() << "file [" << filename << "] doesn't exist" << endl; return false; } // iterate directories and recurse using all *.js files in the directory if (boost::filesystem::is_directory(p)) { boost::filesystem::directory_iterator end; bool empty = true; for (boost::filesystem::directory_iterator it (p); it != end; it++) { empty = false; boost::filesystem::path sub(*it); if (!endsWith(sub.string().c_str(), ".js")) continue; if (!execFile(sub.string(), printResult, reportError, timeoutMs)) return false; } if (empty) { log() << "directory [" << filename << "] doesn't have any *.js files" << endl; return false; } return true; } File f; f.open(filename.c_str(), true); fileofs fo = f.len(); if (fo > kMaxJsFileLength) { warning() << "attempted to execute javascript file larger than 2GB" << endl; return false; } unsigned len = static_cast<unsigned>(fo); boost::scoped_array<char> data (new char[len+1]); data[len] = 0; f.read(0, data.get(), len); int offset = 0; if (data[0] == '#' && data[1] == '!') { const char* newline = strchr(data.get(), '\n'); if (!newline) return true; // file of just shebang treated same as empty file offset = newline - data.get(); } StringData code(data.get() + offset, len - offset); return exec(code, filename, printResult, reportError, timeoutMs); }
PythonWrapper::PythonWrapper() { Py_Initialize(); initGomTvModule(); globals_ = bp::import("__main__").attr("__dict__"); execFile(":/GomTVLeacher/GOMParser"); qAddPostRoutine(clean); }
int TestMain::invokeSafeOpenGLRenderTest(std::string test) { #if defined USE_OPENGL mConfig.setValue("opengl", 2); mConfig.write(); int ret = execFile(fileName, fileName, "-t", test, 30); log->log("%s: %d", test.c_str(), ret); return ret; #else return -1; #endif }
bool Scope::execFile( const string& filename , bool printResult , bool reportError , bool assertOnError, int timeoutMs ){ path p( filename ); if ( ! exists( p ) ){ cout << "file [" << filename << "] doesn't exist" << endl; if ( assertOnError ) assert( 0 ); return false; } // iterate directories and recurse using all *.js files in the directory if ( is_directory( p ) ){ directory_iterator end; bool empty = true; for (directory_iterator it (p); it != end; it++){ empty = false; path sub (*it); if (!endsWith(sub.string().c_str(), ".js")) continue; if (!execFile(sub.string().c_str(), printResult, reportError, assertOnError, timeoutMs)) return false; } if (empty){ cout << "directory [" << filename << "] doesn't have any *.js files" << endl; if ( assertOnError ) assert( 0 ); return false; } return true; } File f; f.open( filename.c_str() , true ); fileofs L = f.len(); assert( L <= 0x7ffffffe ); char * data = (char*)malloc( (size_t) L+1 ); data[L] = 0; f.read( 0 , data , (size_t) L ); return exec( data , filename , printResult , reportError , assertOnError, timeoutMs ); }
SimpleVisApp::SimpleVisApp(VisItViewer *v, int *argc, char ***argv) : QMainWindow() { viewer = v; setWindowTitle(tr("Simple visualization")); plotType = 0; // Create the window. QWidget *central = new QWidget(this); setCentralWidget(central); QHBoxLayout *hLayout = new QHBoxLayout(central); hLayout->setMargin(10); hLayout->setSpacing(10); QVBoxLayout *leftLayout = new QVBoxLayout(0); leftLayout->setSpacing(10); hLayout->addLayout(leftLayout); scalarLabel = new QLabel(tr("Scalar variables"), central); leftLayout->addWidget(scalarLabel); variables = new QListWidget(central); leftLayout->addWidget(variables); connect(variables, SIGNAL(currentTextChanged(const QString &)), this, SLOT(changeVariable(const QString &))); plotTypeWidget = new QWidget(central); leftLayout->addWidget(plotTypeWidget); QHBoxLayout *ptLayout = new QHBoxLayout(plotTypeWidget); ptLayout->setSpacing(10); ptLayout->addWidget(new QLabel(tr("Plot type"), plotTypeWidget)); plotType = new QButtonGroup(plotTypeWidget); QRadioButton *rb = new QRadioButton(tr("Pseudocolor"), plotTypeWidget); plotType->addButton(rb, 0); ptLayout->addWidget(rb); rb = new QRadioButton(tr("Contour"), plotTypeWidget); plotType->addButton(rb, 1); ptLayout->addWidget(rb); connect(plotType, SIGNAL(buttonClicked(int)), this, SLOT(changePlotType(int))); contourWidget = new QWidget(central); leftLayout->addWidget(contourWidget); QHBoxLayout *cLayout = new QHBoxLayout(contourWidget); cLayout->setSpacing(10); nContours = new QSpinBox(contourWidget); nContours->setRange(1,40); nContours->setValue(10); connect(nContours, SIGNAL(valueChanged(int)), this, SLOT(setNContours(int))); cLayout->addWidget(new QLabel(tr("Number of contours"), contourWidget)); cLayout->addWidget(nContours); // Create the vis window directly. viswin = new vtkQtRenderWindow(central); viswin->setMinimumSize(QSize(500,500)); hLayout->addWidget(viswin, 100); // Create menus QMenu *fileMenu = menuBar()->addMenu(tr("File")); fileMenu->addAction(tr("Open . . ."), this, SLOT(selectFile())); fileMenu->addAction(tr("Open commands. . ."), this, SLOT(execFile())); fileMenu->addSeparator(); fileMenu->addAction(tr("Save window"), this, SLOT(saveWindow())); fileMenu->addSeparator(); fileMenu->addAction(tr("Quit"), this, SLOT(quitApp())); QMenu *controlsMenu = menuBar()->addMenu(tr("Controls")); controlsMenu->addAction(tr("Open GUI"), this, SLOT(openGUI())); // // Register a window creation function (before Setup) that will // return the vtkQtRenderWindow objects that we've already // parented into our interface. // viewer->SetWindowCreationCallback(ReturnVisWin, (void *)this); // Set the initial widget sensitivity. resetWindow(); cmd = 0; if (*argc > 1) clfilename = (*argv)[1]; }
static int findHelpItem(meUByte *item, int silent) { meWindow *wp ; meBuffer *bp, *hbp ; meLine *lp, *elp ; int sectLen, itemLen, ii ; meUByte *ss, cc, sect[5] ; itemLen = meStrlen(item) ; if((item[itemLen-1] == ')') && ((item[(ii=itemLen-3)] == '(') || (item[(ii=itemLen-4)] == '(') )) { sectLen = itemLen-ii-2 ; meStrcpy(sect,item+ii) ; itemLen = ii ; item[itemLen] = '\0' ; } else { sectLen = 0 ; sect[0] = '\0' ; sect[1] = '\0' ; } if((hbp=helpBufferFind()) == NULL) return meABORT ; elp = hbp->baseLine ; try_again: lp = meLineGetNext(elp) ; while(lp != elp) { if((lp->text[0] == '!') && (!sectLen || ((sect[1] == lp->text[2]) && (((sectLen == 1) && (lp->text[3] == ' ')) || (sect[2] == lp->text[3]))))) { if((cc=lp->text[1]) == ' ') { ii = meLineGetLength(lp) - 4 ; if(ii != itemLen) ii = -1 ; } else { ii = cc - '0' ; if(ii > itemLen) ii = -1 ; } if((ii > 0) && !meStrncmp(item,lp->text+4,ii)) break ; } lp = meLineGetNext(lp) ; } if(lp == elp) { meMacro *mac ; if(!meModeTest(hbp->mode,MDLOCK)) { if(helpBufferLoad(hbp) == meABORT) return meABORT ; goto try_again ; } if((getMacroTypeS(item) == TKCMD) && ((ii = decode_fncname(item,1)) >= CK_MAX) && ((mac = getMacro(ii)) != NULL) && (mac->hlp->flag & meMACRO_FILE)) { meModeClear(hbp->mode,MDVIEW) ; if(mac->fname != NULL) execFile(mac->fname,0,1) ; else execFile(mac->name,0,1) ; helpBufferReset(hbp) ; if(!(mac->hlp->flag & meMACRO_FILE)) goto try_again ; } if(!silent) mlwrite(MWABORT,(meUByte *)"[Can't find help on %s%s]",item,sect); return meABORT ; } if((wp = meWindowPopup(BhelpN,BFND_CREAT|BFND_CLEAR|WPOP_USESTR,NULL)) == NULL) return false ; if((sectLen == 0) && (lp->text[2] != ' ')) { ss = sect ; *ss++ = '(' ; *ss++ = lp->text[2] ; if(lp->text[3] != ' ') *ss++ = lp->text[3] ; *ss++ = ')' ; *ss = '\0' ; } bp = wp->buffer ; /* Add the header */ { meUByte buff[meBUF_SIZE_MAX] ; sprintf((char *)buff,"\033cD%s%s\033cA",lp->text+4,sect) ; addLineToEob(bp,buff) ; addLineToEob(bp,(meUByte *)"\n\033lsMicroEmacs\033lm[Home]\033le \033lsCommand G\033lm[Commands]\033le \033lsVariable \033lm[Variables]\033le \033lsMacro Lan\033lm[Macro-Dev]\033le \033lsGlobal G\033lm[Glossary]\033le") ; memset(buff,boxChars[BCEW],78) ; buff[78] = '\n' ; buff[79] = '\0' ; addLineToEob(bp,buff) ; } while(((lp=meLineGetNext(lp)) != elp) && (lp->text[0] == '!')) ; while((lp != elp) && ((cc=lp->text[0]) != '!')) { if(cc == '|') { if(meStrcmp(item,lp->text+1)) lp = meLineGetNext(lp) ; } else if(cc == '$') { if(lp->text[1] == 'a') { if(sect[1] == '5') { meUByte line[meBUF_SIZE_MAX], *ss ; if((ss = getval(item)) != NULL) { addLineToEob(bp,(meUByte *)"\n\n\033cEVALUE\033cA\n") ; meStrcpy(line," \"") ; meStrncpy(line+5,ss,meBUF_SIZE_MAX-13) ; line[meBUF_SIZE_MAX-2] = '\0' ; meStrcat(line,"\"") ; addLineToEob(bp,line) ; } } if(sect[1] == '2') { if((ii = decode_fncname(item,1)) >= 0) { meBind *ktp ; meUByte line[meBUF_SIZE_MAX], *ss ; addLineToEob(bp,(meUByte *)"\n\n\033cEBINDINGS\033cA\n") ; meStrcpy(line," ") ; ss = line+4 ; for(ktp = &keytab[0] ; ktp->code != ME_INVALID_KEY ; ktp++) { if(ktp->index == ii) { *ss++ = '"' ; meGetStringFromKey(ktp->code,ss); ss += meStrlen(ss) ; *ss++ = '"' ; *ss++ = ' ' ; } } if(ss == line+4) meStrcpy(ss,"none") ; else *ss = '\0' ; addLineToEob(bp,line) ; } } } } else addLineToEob(bp,lp->text) ; lp = meLineGetNext(lp) ; } /* Add the footer */ { meUByte buff[meBUF_SIZE_MAX] ; buff[0] = '\n' ; memset(buff+1,boxChars[BCEW],78) ; sprintf((char *)buff+79,"\n\033lsCopyright\033lm%s\033le",meCopyright) ; addLineToEob(bp,buff) ; } bp->dotLine = meLineGetNext(bp->baseLine); bp->dotOffset = 0 ; bp->dotLineNo = 0 ; meModeClear(bp->mode,MDEDIT) ; /* don't flag this as a change */ meModeSet(bp->mode,MDVIEW) ; /* put this buffer view mode */ resetBufferWindows(bp) ; /* Update the window */ mlerase(MWCLEXEC); /* clear the mode line */ return true ; }
void SpatialiteBackend::InitializeNew() { execFile(":/Utils/Spatialite/init_spatialite-2.3.sql"); // // Tables pour gérer les features. // exec( "CREATE TABLE IF NOT EXISTS feature (" " type UNSIGNED CHAR," " id INTEGER," " version INTEGER," " timestamp TIMESTAMP," " user TEXT DEFAULT NULL," " PRIMARY KEY (type, id)" " );" "SELECT AddGeometryColumn('feature', 'GEOMETRY', 4326, 'GEOMETRY', 2);" "SELECT CreateSpatialIndex('feature','GEOMETRY');" "CREATE TABLE IF NOT EXISTS feature_tags (" " id_feature INTEGER NOT NULL REFERENCES feature," " id_tag INTEGER NOT NULL REFERENCES tag," " PRIMARY KEY (id_feature, id_tag))" ); // // Table pour stocker les tags (pour tous les éléments). // exec("CREATE TABLE IF NOT EXISTS tag (" "id INTEGER PRIMARY KEY AUTOINCREMENT," "key TEXT," "value TEXT," "UNIQUE (key, value))"); // // Tables pour gérer les way. // exec( "CREATE TABLE IF NOT EXISTS way_nodes (" " id_way INTEGER REFERENCES feature," " rang INTEGER(5)," " id_node INTEGER REFERENCES feature," " PRIMARY KEY (id_way, rang));" ); // // Tables pour gérer les relations. // exec( "CREATE TABLE IF NOT EXISTS relation_members (" " id_relation INTEGER NOT NULL REFERENCES feature," " rang INTEGER(5)," " type INTEGER(1) NOT NULL," " id_member INTEGER NOT NULL," " role TEXT NULL," " PRIMARY KEY (id_relation, rang, type, id_member))"); fSelectFeature = SpatialStatement(this, "SELECT ROWID from feature where (type = ? AND id = ?)"); fSelectFeatureBbox = SpatialStatement(this, "SELECT * from feature where ROWID IN " "(Select rowid from idx_feature_Geometry WHERE xmax > ? and ymax > ? and xmin < ? and ymin < ?);"); fSelectTag = SpatialStatement(this, "SELECT id FROM tag WHERE (key=? AND value=?)"); fInsertTag = SpatialStatement(this, "INSERT INTO tag (key, value) VALUES (?,?)"); fCreateFeature = SpatialStatement(this, "INSERT INTO feature (type) VALUES (?)"); fUpdateFeature = SpatialStatement(this, "UPDATE feature set version=?,uid=?,actor=?,virtual=?,deleted=?,special=?,uploaded=?,dirtylevel=?,timestamp=?,bbox=?) WHERE ROWID=?"); fInsertFeatureTags = SpatialStatement(this, "INSERT INTO feature_tags (id_feature, id_tag) VALUES (?,?)"); fInsertWayNodes = SpatialStatement(this, "INSERT INTO way_nodes (id_way, id_node, rang) VALUES (?,?,?)"); fInsertRelationMembers = SpatialStatement(this, "INSERT INTO relation_members (id_relation, type, id_member, role, rang) VALUES (?,?,?,?,?)"); exec("PRAGMA cache_size = 10000"); exec("PRAGMA synchronous = OFF"); // exec("PRAGMA journal_mode = OFF"); exec("PRAGMA temp_store = MEMORY"); exec("PRAGMA locking_mode = EXCLUSIVE"); }