Beispiel #1
0
int bmx_wxshell(BBString * command) {
	if (command == &bbEmptyString) {
		return static_cast<int>(wxShell());
	} else {
		return static_cast<int>(wxShell(wxStringFromBBString(command)));
	}
}
void Calendario::Options(wxCommandEvent& event)
{
#ifdef WIN32
	wxShell(wxString::Format(_("%s\\Divel\\Calendar\\conf.cfg"),getenv("appdata"))); //GEDIT en LINUX
#else
	wxShell(wxString::Format(_("gedit %s/Divel/Calendar/conf.cfg"),getenv("HOME")));
#endif WIN32
}
Beispiel #3
0
void CDStarRepeaterApp::OnRemoteCmd(wxThreadEvent& event)
{
	wxLogMessage("Request to execute command %s (%d)",
		m_commandLine[event.GetInt()], event.GetInt());
	// XXX sanity check the command line here.
	wxShell(m_commandLine[event.GetInt()]);
}
void MyFrame::OnActualizar(wxCommandEvent& WXUNUSED(event))
{
	wxShell("update-manager -d");//Solo Ubuntu
	/*
	AZPUpdater* azpupdater;
	azpupdater=new AZPUpdater();
	azpupdater->CheckUpdates();*/
}
Beispiel #5
0
wxSize SlideShow::ToGif(wxString file)
{
  wxArrayString which;
  bool success = true;

  wxString convert(wxT("convert -delay "+wxString::Format(wxT("%i"),100/GetFrameRate())));
  wxString convertArgs;

  wxString tmpdir = wxFileName::GetTempDir();

  for (int i=0; i<m_size; i++)
  {
    wxFileName imgname(tmpdir, wxString::Format(wxT("wxm_anim%d.png"), i));

    wxImage image = m_images[i]->ToImageFile(imgname.GetFullPath());

    convert << wxT(" \"") << imgname.GetFullPath() << wxT("\"");
  }

  convert << wxT(" \"") << file << wxT("\"");

#if defined __WXMSW__
  if (!wxShell(convert))
#else
  if (wxExecute(convert, wxEXEC_SYNC) != 0)
#endif
  {
    success = false;
    wxMessageBox(_("There was an error during GIF export!\n\nMake sure ImageMagick is installed and wxMaxima can find the convert program."),
        wxT("Error"), wxICON_ERROR);
  }

  for (int i=0; i<m_size; i++)
  {
    wxFileName imgname(tmpdir, wxString::Format(wxT("wxm_anim%d.png"), i));
    wxRemoveFile(imgname.GetFullPath());
  }

  if(success)
  {
    if(m_size>0)
      return wxSize(m_images[1]->GetOriginalWidth(),m_images[1]->GetOriginalHeight());
    else
    {
      wxSize retval;
      retval.x=retval.y=0;
      return retval;
    }
  }
  else
  {
    wxSize retval;
    retval.x=retval.y=-1;
    return retval;
  }
}
void LauncherApp::jreInstall()
{
#ifdef __WINDOWS__
  if (!run_external(params["jre"]))
#else
  if (!wxShell(params["jre"]))
#endif
  {
    error(_("Could not launch the JRE installation process."));
  }

  runJRE();
  completed = true;
}
Beispiel #7
0
bool SlideShow::ToGif(wxString file)
{
  wxArrayString which;
  bool retval = true;

  wxString convert(wxT("convert -delay 40 "));
  wxString convertArgs;

  wxString tmpdir = wxFileName::GetTempDir();

  for (int i=0; i<m_size; i++)
  {
    wxFileName imgname(tmpdir, wxString::Format(wxT("wxm_anim%d.png"), i));

    wxImage image = m_bitmaps[i]->ConvertToImage();
    image.SaveFile(imgname.GetFullPath(), wxBITMAP_TYPE_PNG);

    convert << wxT(" \"") << imgname.GetFullPath() << wxT("\"");
  }

  convert << wxT(" \"") << file << wxT("\"");

#if defined __WXMSW__
  if (!wxShell(convert))
#else
  if (wxExecute(convert, wxEXEC_SYNC) != 0)
#endif
  {
    retval = false;
    wxMessageBox(_("There was and error during GIF export!\n\nMake sure ImageMagick is installed and wxMaxima can find the convert program."),
        wxT("Error"), wxICON_ERROR);
  }

  for (int i=0; i<m_size; i++)
  {
    wxFileName imgname(tmpdir, wxString::Format(wxT("wxm_anim%d.png"), i));
    wxRemoveFile(imgname.GetFullPath());
  }

  return retval;
}
Beispiel #8
0
void ProcUtils::ExecuteInteractiveCommand(const wxString &command)
{
    wxShell(command);
}
/* wxHTTP randomly crashes when called on a worker thread, this must be called from main thread ! */
wxString CXLXHostsFileDownloader::Download(const wxString & xlxHostsFileURL)
{
#ifdef XLX_USE_WGET
	wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_"));
	wxString commandLine = _T("wget -q -O ") + xlxHostsFileName + _T(" ") + xlxHostsFileURL;
	bool execResult = wxShell(commandLine);
	
	if(!execResult) {
		wxLogError(_T("Unable do download XLX host file, make sure wget is installed"));
		return wxEmptyString;
	}
	
	return xlxHostsFileName;
#else
	wxHTTP http;
	http.SetNotify(false);
	http.SetFlags(wxSOCKET_WAITALL);
	http.SetHeader( _T("Accept") , _T("text/*") );
	http.SetHeader( _T("User-Agent"), _T("ircddbGateway") );
	http.SetTimeout(5); // seconds

	wxLogMessage(_T("Downloading XLX reflector list from %s"), xlxHostsFileURL.c_str());

	// remove "http://" from the url, i.e. minus 7 chars
	size_t len = xlxHostsFileURL.length();
	wxString path = xlxHostsFileURL.Right(len-7);
	
	// find the first forward slash
	int slash = path.Find(wxChar('/'));
	len = path.length();
	wxString server = path.Left(slash);
	path = path.Right(len-slash);

	// Note that Connect() wants a host address, not an URL. 80 is the server's port.
	if(!http.Connect(server, 80 )) {
		wxLogError(_T("Failed to connect to %s"), server);
		return wxEmptyString;
	}
	
	wxInputStream* in = NULL;
	if((in = http.GetInputStream(path)) && in->IsOk()) {
		wxFile file;
		wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_"), &file);
		wxLogMessage(_T("Created temporary file %s"), xlxHostsFileName);
		if(!file.IsOpened()) {
			wxLogError(_T("Failed to open temporary file %s"), xlxHostsFileName);
			wxDELETE(in);
			return wxEmptyString;
		}
		
		//in->Read(fileStream);
		//fileStream.Write(*in);
		//in->Read(tempFileStream);
		//Both call above seem to not work when run in a separate thread, hence the old fashion loop below
		unsigned char buffer[2048];
		while(!in->Eof()) {
			in->Read(buffer, 2048);
			int readCount = in->LastRead();
			if(readCount <= 0)
				break;

			file.Write(buffer, readCount);
		}
		wxLogMessage(_T("XLX Successfuly downloaded to %s"), xlxHostsFileName);
		file.Close();
		http.Close();
		wxDELETE(in);
		return xlxHostsFileName;
	}
	
	wxLogError(_T("Failed to get HTTP stream"));
	if(in) wxDELETE(in);

	return wxEmptyString;
#endif
}
Beispiel #10
0
void ExecTestCase::TestShell()
{
    CPPUNIT_ASSERT( wxShell(SHELL_COMMAND) );
}
//----------------------------------------------------------------------------
void medLogicWithManagers::OnEvent(mafEventBase *maf_event)
//----------------------------------------------------------------------------
{
	if (mafEvent *e = mafEvent::SafeDownCast(maf_event))
	{
		switch(e->GetId())
		{
		  case ABOUT_APPLICATION:
			{
        // trap the ABOUT_APPLICATION event and shows the about window with the application infos
				wxString message = m_AppTitle.GetCStr();
				message += _(" Application ");
				message += m_Revision;
				wxMessageBox(message, "About Application");
				mafLogMessage(wxString::Format("%s",m_Revision.GetCStr()));
			}
		 break;
		 case ID_GET_FILENAME:
			  {
				  e->SetString(&(m_VMEManager->GetFileName()));
			  }
			  break;
		 case MENU_FILE_SNAPSHOT:
			  {
				  mafString msfFilename = m_VMEManager->GetFileName();
				  if (msfFilename.IsEmpty())
				  {
					  mafString dirName = mafGetApplicationDirectory().c_str();
					  dirName << "\\data\\msf\\";

					  m_VMEManager->SetDirName(dirName);
					  this->OnFileSaveAs();
					  this->OnEvent((mafEventBase*)&mafEvent(this,CAMERA_UPDATE));
					  msfFilename = m_VMEManager->GetFileName();
				  }

				  wxString path, name, ext;
				  wxSplitPath(msfFilename.GetCStr(),&path,&name,&ext);
				  wxString imagesDirectoryName = path;
				  imagesDirectoryName += "/images";
				  if (!::wxDirExists(imagesDirectoryName))
				  {
					  ::wxMkdir(imagesDirectoryName);
				  }

				  wxDir imagesDirectory(imagesDirectoryName);
				  wxString filename;
				  int i = 0;
				  bool cont = imagesDirectory.GetFirst(&filename);
				  while ( cont )
				  {
					  i++;
					  cont = imagesDirectory.GetNext(&filename);
				  }

				  if (e->GetString() && !(e->GetString()->IsEmpty()))
				  {
					  mafString *imageFileName = new mafString();
					  imageFileName->Append(imagesDirectoryName.c_str());
					  imageFileName->Append("/");
					  imageFileName->Append(e->GetString()->GetCStr());
					  imageFileName->Append(wxString::Format("_%d",i));
					  imageFileName->Append(".png");

					  /*mafRWIBase::SafeDownCast(e->GetVtkObj())->SaveImage(imageFileName);*/
					  e->SetString(imageFileName);

					  wxString path,name,ext;
					  wxSplitPath(imageFileName->GetCStr(),&path,&name,&ext);
					  wxString oldWD = wxGetWorkingDirectory();
					  wxSetWorkingDirectory(path);
					  wxString command = "START  ";
					  command = command + name+"."+ext;
					  wxExecute( command );
					  wxSetWorkingDirectory(oldWD);


				  }
				  else
				  {
					  wxString imageFileName = "";
					  mafViewCompound *v = mafViewCompound::SafeDownCast(m_ViewManager->GetSelectedView());
					  if (v)
					  {
						  imageFileName = imagesDirectoryName;
						  imageFileName << "/";
						  wxString tmpImageFile;
						  tmpImageFile << v->GetLabel();
						  tmpImageFile << i;
						  tmpImageFile << ".png";

						  tmpImageFile.Replace(" ","_");

						  imageFileName << tmpImageFile;

						  v->GetRWI()->SaveAllImages(imageFileName,v, m_ApplicationSettings->GetImageTypeId());

						  wxMessageBox(_("Snapshot saved!"));
					  }
					  else
					  {
						  mafView *v = m_ViewManager->GetSelectedView();

						  imageFileName = imagesDirectoryName;
						  imageFileName << "/";
						  wxString tmpImageFile;
						  tmpImageFile << v->GetLabel();
						  tmpImageFile << i;
						  tmpImageFile << ".png";

						  tmpImageFile.Replace(" ","_");

						  imageFileName << tmpImageFile;

						  if (v)
						  {
							  v->GetRWI()->SaveImage(imageFileName);
							  wxMessageBox(_("Snapshot saved!"));
						  }
					  }

					  wxString path,name,ext;
					  wxSplitPath(imageFileName,&path,&name,&ext);
					  wxString oldWD = wxGetWorkingDirectory();
					  wxSetWorkingDirectory(path);
					  wxString command = "START  ";
					  command = command + name+"."+ext;
					  wxShell( command );
					  wxSetWorkingDirectory(oldWD);
				  }

				  OnEvent(&mafEvent(this,WIZARD_RUN_CONTINUE,true));
			  }
		break;
     case MENU_WIZARD:
      //The event from the application menu
      if(m_WizardManager) 
        m_WizardManager->WizardRun(e->GetArg());
     break;
     case WIZARD_RUN_STARTING:
      {
        //Manage start event from the wizard lock window close button
        //and disabling toolbar
        mafGUIMDIChild *c = (mafGUIMDIChild *)m_Win->GetActiveChild();
        if (c != NULL)
          c->SetAllowCloseWindow(false);
        WizardRunStarting();
      }
     break; 
     case WIZARD_RUN_TERMINATED:
      {
        //Manage end event from the wizard unlock window close button
        //and enabling toolbar
        mafGUIMDIChild *c = (mafGUIMDIChild *)m_Win->GetActiveChild();
        if (c != NULL)
          c->SetAllowCloseWindow(true);
        WizardRunTerminated();
        UpdateFrameTitle();
      }
    break;
	 case WIZARD_RUN_CONTINUE:
	 {
		 if (m_WizardManager && m_WizardRunning)
			 m_WizardManager->WizardContinue(e->GetBool());
	 }
	 break;
    case WIZARD_UPDATE_WINDOW_TITLE:
       {
         UpdateFrameTitle();
       }
    break;
    case WIZARD_REQUIRED_VIEW:
       {
         //The wizard requires a specific view
         //searching on open views or open a new one
         mafView *view;
         const char *viewStr=e->GetString()->GetCStr();
         
         view=m_ViewManager->GetFromList(viewStr);
         if (view)
           m_ViewManager->Activate(view);
         else
           m_ViewManager->ViewCreate(viewStr);
       }
    break;
	case WIZARD_DELETE_VIEW:
		{
			mafView *view;
			const char *viewStr=e->GetString()->GetCStr();

			view=m_ViewManager->GetFromList(viewStr);
			if (view) 
			{
				mafGUIMDIChild *c = (mafGUIMDIChild *)view->GetFrame();
				m_ViewManager->ViewDelete(view);
				if (c != NULL)
					c->Destroy();
			}
		}
	break;
    case WIZARD_RUN_OP:
      {
        //Running an op required from the wizard
        mafString *tmp=e->GetString();
        mafLogMessage("wiz starting :%s",tmp->GetCStr());
        m_CancelledBeforeOpStarting=true;
        UpdateFrameTitle();
        m_OpManager->OpRun(*(e->GetString()));
        //If the op is started the value of m_CancelledBeforeOpStarting 
        //is changed by OP_RUN_STARTING event
        if (m_CancelledBeforeOpStarting)
        {
          m_CancelledBeforeOpStarting=false;
           m_WizardManager->WizardContinue(false);
        }
        
      }
    break;
    case WIZARD_OP_DELETE:
      {
        //Running an op required from the wizard
        m_CancelledBeforeOpStarting=true;
        UpdateFrameTitle();
        m_OpManager->OpRun(OP_DELETE);
        m_WizardManager->WizardContinue(true);
      }
    break;
    case WIZARD_OP_NEW:
      {
        //Running an op required from the wizard
        if(m_VMEManager)
          m_VMEManager->MSFNew();
        m_WizardManager->WizardContinue(true);
      }
    break;
    case WIZARD_PAUSE:
      {
        UpdateFrameTitle();
        m_OpManager->OpRun(e->GetOp());
      }
      break;
    case WIZARD_RELOAD_MSF:
      {
        UpdateFrameTitle();
        wxString file;
        file=m_VMEManager->GetFileName().GetCStr();
        if(file.IsEmpty())
        {
          mafLogMessage ("Reload requested whitout opened MSF");
          //continue wizard with error
          m_WizardManager->WizardContinue(false);
        }
        else
        {
          int opened=m_VMEManager->MSFOpen(file);
          //continue wizard after open operation
          m_WizardManager->WizardContinue(opened!=MAF_ERROR);
        }
      }
      break;
    case OP_RUN_STARTING:
      {
        mafLogMessage("run starting");
        m_CancelledBeforeOpStarting=false;
        mafLogicWithManagers::OnEvent(maf_event);
      }
    break;
    case OP_RUN_TERMINATED:
      {
        //if the operation was started from the wizard we continue the wizard execution
        if (m_WizardManager && m_WizardRunning)
        {
          m_WizardManager->WizardContinue(e->GetArg());
        }
        //else we manage the operation end by unlock the close button and so on
        else
        {
          mafGUIMDIChild *c = (mafGUIMDIChild *)m_Win->GetActiveChild();
          if (c != NULL)
            c->SetAllowCloseWindow(true);
          OpRunTerminated();
        }
      }
      break; 
	case MENU_VIEW_TOOLBAR:
		m_Win->ShowDockPane("wizardgauge",!m_Win->DockPaneIsShown("wizardgauge") );
		m_Win->ShowDockPane("tmpwithtest",!m_Win->DockPaneIsShown("tmpwithtest") );
		m_Win->ShowDockPane("separator",!m_Win->DockPaneIsShown("separator") );
		mafLogicWithManagers::OnEvent(maf_event);
		break;
    case PROGRESSBAR_SHOW:
     {
       if (e->GetSender()==m_WizardManager)
       {
         m_WizardLabel->Enable();
         m_WizardGauge->Enable();
       }
       else
         mafLogicWithManagers::OnEvent(maf_event);
     }
    break;
    case PROGRESSBAR_HIDE:
      {
        if (e->GetSender()==m_WizardManager)
        {
          m_WizardGauge->SetValue(0);
          m_WizardGauge->Enable(false);
          m_WizardLabel->Enable(false);
        }
        else
          mafLogicWithManagers::OnEvent(maf_event);
      }
    break;
    case PROGRESSBAR_SET_VALUE:
      {
        if (e->GetSender()==m_WizardManager)
          m_WizardGauge->SetValue(e->GetArg());
        else
          mafLogicWithManagers::OnEvent(maf_event);
      }
    break;
		default:
      //Call parent event manager
			mafLogicWithManagers::OnEvent(maf_event);
			break; 
		} // end switch case
	} // end if SafeDowncast
}
Beispiel #12
0
long restore_table(const wxString& host,const  wxString& user, const wxString& password, const wxString& db_name, const wxString& filename)
{
    wxString command = _T("mysql < ") + filename + _T(" --user="******" --password="******" --host=") + host + _T(" --database=") + db_name;
    long result = wxShell(command);
    return result;
}
Beispiel #13
0
long make_dump(const wxString& host,const  wxString& user, const wxString& password, const wxString& db_name, const wxString& filename)
{
    wxString command = _T("mysqldump --user="******" --password="******" --host=") + host + _T(" --result-file=") + filename + _T(" ") + db_name;
    long result = wxShell(command);
    return result;
}
void MyFrame::OnInstrucciones(wxCommandEvent& WXUNUSED(event))
{
		wxShell("firefox http://sites.google.com/site/divelmedia");	//meter un pdf
}
void MyFrame::OnNet(wxCommandEvent& WXUNUSED(event))
{
	//DEBUG MODE
	wxShell("firefox http://sites.google.com/site/divelstore");
}