public override void Open() { SafeProcess p = new SafeProcess(); switch (Hit.Source) { case "Tomboy": // This doesn't work very well if you have multiple // terms that match. Tomboy doesn't seem to have a way // to specify more than one thing to highlight. p.Arguments = new string [] { "tomboy", "--open-note", Hit.EscapedUri, "--highlight-search", Query.QuotedText }; break; case "Labyrinth": p.Arguments = new string [] { "labyrinth", "-m", Hit.FileInfo.Name }; break; case "EvolutionDataServer": p.Arguments = new string [] { "evolution", Hit.EscapedUri }; break; } try { p.Start(); } catch (Exception e) { Console.WriteLine("Could not open note: " + e); } }
protected virtual void OnSendEmail(object o, EventArgs args) { string mail = null; SafeProcess process; if (contact ["PrimaryEmail"] != null) { mail = contact ["PrimaryEmail"] as string; } else if (contact ["SecondEmail"] != null) { mail = contact ["SecondMail"] as string; } else { MessageDialog dialog = new MessageDialog( null, DialogFlags.DestroyWithParent, MessageType.Warning, ButtonsType.Ok, Catalog.GetString("Could not find a valid E-mail address!")); dialog.Run(); dialog.Destroy(); return; } process = new SafeProcess(); process.Arguments = new string [2]; process.Arguments [0] = Thunderbird.ExecutableName; process.Arguments [1] = String.Format("mailto:{0}", mail); process.Start(); }
private bool InitDoPull() { // create new external process pc = new SafeProcess(); pc.Arguments = new string [] { "pdftotext", "-q", "-nopgbrk", "-enc", "UTF-8", FileInfo.FullName, "-" }; pc.RedirectStandardOutput = true; // FIXME: This should really be true, and we should // process the output. But we can deadlock when // pdftotext is blocked writing to stderr because of a // full buffer and we're blocking while reading from // stdout. pc.RedirectStandardError = false; // Let pdftotext run for at most 90 CPU seconds, and not // use more than 100 megs memory. pc.CpuLimit = 90; pc.MemLimit = 100 * 1024 * 1024; try { pc.Start(); } catch (SafeProcessException e) { Log.Warn(e.Message); Error(); return(false); } // add pdftotext's output to pool pout = new StreamReader(pc.StandardOutput); pull_started = true; return(true); }
static string getLangMap() { SafeProcess langmapPc = new SafeProcess(); string[] args = new string[1]; args[0] = "lang-map-for-ctags"; langmapPc.Arguments = args; langmapPc.Start(); return(new StreamReader(langmapPc.StandardOutput).ReadToEnd()); }
public void FindAllFromSender() { SafeProcess p = new SafeProcess(); string addr = Hit.GetFirstProperty("fixme:from_address"); p.Arguments = new string [] { "beagle-search", String.Format("mailfromaddr:{0}", addr) }; try { p.Start(); } catch (Exception e) { Console.WriteLine("Error launching new search: " + e.Message); } }
public override void Open() { SafeProcess p = new SafeProcess(); p.Arguments = new string [] { "evolution", Hit.EscapedUri }; try { p.Start(); } catch (SafeProcessException e) { Console.WriteLine(e.Message); } }
private void OnNetworkConfigure(object o, EventArgs args) { SafeProcess p = new SafeProcess(); p.Arguments = new string[] { "beagle-settings", "--networking" }; try { p.Start(); } catch (Exception e) { Console.WriteLine("Could not start beagle-settings:\n{0}", e); } }
public void FindFromHost() { SafeProcess p = new SafeProcess(); //string addr = Search.Tiles.Utils.GetFirstPropertyOfParent(Hit,"fixme:from_address"); p.Arguments = new string [] { "beagle-search", String.Format("host:{0}", Hit.Uri.Host) }; try { p.Start(); } catch (Exception e) { Console.WriteLine("Error launching new search: " + e.Message); } }
public override void Open() { SafeProcess p = new SafeProcess(); p.Arguments = new string [] { "yelp", path }; try { p.Start(); } catch { Console.WriteLine("Failed to start '{0}'", p.Arguments [0]); } }
public override void Open() { SafeProcess p = GetClientProcess(Hit.GetFirstProperty("fixme:client"), Hit.EscapedUri); if (p == null) { Console.WriteLine("Opening contact '{0}' is unsupported!", Hit.EscapedUri); return; } try { p.Start(); } catch (SafeProcessException e) { Console.WriteLine(e.Message); } }
public override void Open() { SafeProcess p = MailMessage.GetClientProcess(Hit); if (p == null) { OpenFromMime(Hit); return; } try { p.Start(); } catch (SafeProcessException e) { Console.WriteLine("Unable to run {0}: {1}", p.Arguments [0], e.Message); } }
public void FindSameAuthor() { SafeProcess p = new SafeProcess(); string author = Hit.GetFirstProperty("dc:author"); if (String.IsNullOrEmpty(author)) { author = Hit.GetFirstProperty("dc:creator"); } p.Arguments = new string [] { "beagle-search", String.Format("author:{0} OR creator:{0}", author) }; try { p.Start(); } catch (Exception e) { Console.WriteLine("Error launching new search: " + e.Message); } }
private static void RunDefaultHandler (string command, string uri) { string[] argv; argv = new string [] { command, uri }; Console.WriteLine ("Cmd: {0}", command); Console.WriteLine ("Uri: {0}", uri); SafeProcess p = new SafeProcess (); p.Arguments = argv; try { p.Start (); } catch (Exception e) { Console.WriteLine ("Error in OpenFromMime: " + e); } }
private bool RunExtractor() { string extractor_path, exe; // Hack, along with magic in beagled-index-helper.in // and tools/wrapper.in to make this work in the // uninstalled case. extractor_path = Environment.GetEnvironmentVariable("BEAGLE_TOOL_PATH"); if (extractor_path != null) { exe = Path.Combine(extractor_path, "beagle-doc-extractor"); } else { exe = "beagle-doc-extractor"; } pc = new SafeProcess(); pc.Arguments = new string [] { exe, FileInfo.FullName }; pc.RedirectStandardOutput = true; pc.RedirectStandardError = true; pc.UseLangC = true; // Let beagle-doc-extractor run for 90 CPU seconds, max. pc.CpuLimit = 90; // Some documents make wv1 go crazy with memory. Limit // it to 100 megs of address space, too. pc.MemLimit = 100 * 1024 * 1024; try { pc.Start(); } catch (SafeProcessException e) { Log.Warn(e); Error(); return(false); } pout = new StreamReader(pc.StandardOutput); pull_started = true; return(true); }
private bool InitBibparse() { bib_process = new SafeProcess(); bib_process.Arguments = new string[] { "bibparse", FileInfo.FullName }; bib_process.RedirectStandardError = false; bib_process.RedirectStandardOutput = true; bib_process.CpuLimit = 180; // 3 minutes bib_process.MemLimit = 50 * 1024 * 1024; // 50 MB try { bib_process.Start(); } catch (SafeProcessException e) { Log.Error(e, "Error running 'bibparse {0}'", FileInfo.FullName); return(false); } reader = new StreamReader(bib_process.StandardOutput); return(true); }
static FilterBibTex() { // Check if bibparse is present SafeProcess pc = new SafeProcess(); pc.Arguments = new string [] { "bibparse" }; pc.RedirectStandardOutput = false; pc.RedirectStandardError = false; try { pc.Start(); bibparse_installed = true; } catch (SafeProcessException) { Log.Warn("bibparse is not found; bibtex files will not be indexed"); bibparse_installed = false; } pc.Close(); }
// FIXME: fspot doesnt allow to import a particular file // only a whole directory public void AddToLibrary() { // FIXME: check if f-spot is installed if (Hit ["fspot:IsIndexed"] == "true") { return; } SafeProcess p = new SafeProcess(); p.Arguments = new string[] { "f-spot", "--import", Hit.FileInfo.FullName }; try { p.Start(); } catch (Exception e) { Console.WriteLine("Error launching F-Spot: " + e); } }
public override void Open() { // If we are not a feed from Thunderbird just open based on mime if (Hit.GetFirstProperty("fixme:client") != "thunderbird") { base.OpenFromUri(Hit ["dc:identifier"]); return; } #if ENABLE_THUNDERBIRD // Here's the Thunderbird specific part SafeProcess p = Thunderbird.GetSafeProcess("-viewbeagle", Hit.GetFirstProperty("fixme:uri")); try { p.Start(); } catch (SafeProcessException e) { Console.WriteLine("Unable to run {0}: {1}", p.Arguments [0], e.Message); } #endif }
protected override void RegisterSupportedTypes() { // Get the list of mime-types from the totem-video-indexer SafeProcess pc = new SafeProcess(); pc.Arguments = new string [] { "totem-video-indexer", "--mimetype" }; pc.RedirectStandardOutput = true; pc.RedirectStandardError = true; pc.UseLangC = true; try { pc.Start(); } catch (SafeProcessException e) { if (Debug) { Log.Debug(e.Message); } return; } StreamReader pout = new StreamReader(pc.StandardOutput); string str; while ((str = pout.ReadLine()) != null) { FilterFlavor flavor = FilterFlavor.NewFromMimeType(str); flavor.Priority = Priority; AddSupportedFlavor(flavor); if (Debug) { Log.Debug("Added {0} as a supported mime type for Totem video filter", str); } } pout.Close(); pc.Close(); }
public override void Open() { SafeProcess p = new SafeProcess(); string log_path = Hit.Uri.LocalPath; if (Hit.Source == "Konversation") { log_path = Hit.ParentUri.LocalPath; } p.Arguments = new string [] { "beagle-imlogviewer", "--client", Hit ["fixme:client"], "--highlight-search", Query.QuotedText, log_path }; try { p.Start(); } catch (Exception e) { Console.WriteLine("Unable to run {0}: {1}", p.Arguments [0], e.Message); } }
public void RevealInFolder() { string path = Hit.FileInfo.DirectoryName; // FIXME: When nautilus implements this, then we should // also select the file in the folder. SafeProcess p = new SafeProcess(); #if ENABLE_DESKTOP_LAUNCH p.Arguments = new string [] { "desktop-launch", path }; #elif ENABLE_XDG_OPEN p.Arguments = new string [] { "xdg-open", path }; #else p.Arguments = new string [] { "nautilus", "--no-desktop", path }; #endif try { p.Start(); } catch (Exception e) { Console.WriteLine("Cannot open folder: " + e); } }
override protected void DoPull() { // create new external process SafeProcess pc = new SafeProcess(); pc.Arguments = new string [] { "ssindex", "-i", FileInfo.FullName }; pc.RedirectStandardOutput = true; pc.RedirectStandardError = false; pc.UseLangC = true; // Let ssindex run for 10 seconds, max. pc.CpuLimit = 10; try { pc.Start(); } catch (SafeProcessException e) { Log.Warn(e.Message); Error(); return; } // process ssindex output StreamReader pout = new StreamReader(pc.StandardOutput); xmlReader = new XmlTextReader(pout); try { WalkContentNodes(xmlReader); } catch (Exception e) { Logger.Log.Debug("Exception occurred while indexing {0}.", FileInfo.FullName); Logger.Log.Debug(e); } pout.Close(); pc.Close(); Finished(); }
public void SendInMail() { SafeProcess p = new SafeProcess(); string uri; if (Hit.ParentUri != null) { uri = Hit.EscapedParentUri; } else { uri = Hit.EscapedUri; } p.Arguments = new string [] { "evolution", String.Format("{0};forward=attached", uri) }; try { p.Start(); } catch (Exception e) { Console.WriteLine("Error launching Evolution composer: " + e.Message); } }
protected override bool PullPackageProperties() { SafeProcess pc = new SafeProcess(); pc.Arguments = new string [] { "rpm", "-qp", "--queryformat", property_queryformat, FileInfo.FullName }; pc.RedirectStandardOutput = true; pc.UseLangC = true; // Let rpm run for 15 seconds for properties, max. pc.CpuLimit = 15; try { pc.Start(); } catch (SafeProcessException e) { Log.Warn(e.Message); return(false); } StreamReader pout = new StreamReader(pc.StandardOutput); // Order is dependent on the queryformat string PackageName = ReadString(pout); PackageVersion = ReadString(pout); Summary = ReadString(pout); Category = ReadString(pout); License = ReadString(pout); Packager = ReadString(pout); Homepage = ReadString(pout); string size = ReadString(pout); Size = Convert.ToInt64(size); pout.Close(); pc.Close(); return(true); }
protected override void DoPull() { SafeProcess pc = new SafeProcess(); pc.Arguments = new string [] { "rpm", "-qp", "--queryformat", text_queryformat, FileInfo.FullName }; pc.RedirectStandardOutput = true; // Let rpm run for 90 seconds for text, max. pc.CpuLimit = 90; try { pc.Start(); } catch (SafeProcessException e) { Log.Warn(e.Message); Error(); return; } StreamReader pout = new StreamReader(pc.StandardOutput); string s; while ((s = pout.ReadLine()) != null) { if (s == "(none)") { continue; } AppendWord(s); } pout.Close(); pc.Close(); Finished(); }
static FilterText() { if (Environment.GetEnvironmentVariable("SOURCECODETAGSMODE") == "true") { sourceCodeTagsMode = true; ctagsPc = new SafeProcess(); string[] args = new string[7]; args[0] = "ctags-ajoke"; args[1] = "--langmap=" + getLangMap(); args[2] = "-xu"; args[3] = "--filter"; args[4] = "--filter-terminator=###terminator###\n"; args[5] = "--extra=+q"; args[6] = "--c-kinds=+p"; ctagsPc.Arguments = args; ctagsPc.RedirectStandardOutput = true; ctagsPc.RedirectStandardInput = true; ctagsPc.Start(); ctagsInput = new StreamWriter(ctagsPc.StandardInput); ctagsOutput = new StreamReader(ctagsPc.StandardOutput); } }
protected override void DoPullProperties() { if (FileInfo == null) { Log.Error("FilterTotem: Unable to extract properties for non-file data"); Error(); return; } SafeProcess pc = new SafeProcess(); pc.Arguments = new string [] { "totem-video-indexer", FileInfo.FullName }; pc.RedirectStandardOutput = true; pc.RedirectStandardError = true; // Let totem run for 10 seconds, max. pc.CpuLimit = 10; try { pc.Start(); } catch (SafeProcessException e) { Log.Warn(e.Message); Error(); return; } StreamReader pout = new StreamReader(pc.StandardOutput); string str; while ((str = pout.ReadLine()) != null) { if (!str.StartsWith("TOTEM_INFO_")) { continue; } string[] tokens = str.Split('='); if (tokens.Length != 2) { continue; } switch (tokens [0]) { case "": break; case "TOTEM_INFO_TITLE": AddProperty(Beagle.Property.New("dc:title", tokens [1])); break; case "TOTEM_INFO_ARTIST": AddProperty(Beagle.Property.New("fixme:artist", tokens [1])); break; case "TOTEM_INFO_YEAR": AddProperty(Beagle.Property.New("fixme:year", tokens [1])); break; case "TOTEM_INFO_ALBUM": AddProperty(Beagle.Property.New("fixme:album", tokens [1])); break; case "TOTEM_INFO_DURATION": //FIXME dc:extent or fixme:duration??? AddProperty(Beagle.Property.NewUnsearched("dc:extent", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_TRACK_NUMBER": AddProperty(Beagle.Property.NewUnsearched("fixme:tracknumber", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_HAS_VIDEO": break; case "TOTEM_INFO_VIDEO_WIDTH": AddProperty(Beagle.Property.NewUnsearched("fixme:video:width", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_VIDEO_HEIGHT": AddProperty(Beagle.Property.NewUnsearched("fixme:video:height", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_VIDEO_CODEC": AddProperty(Beagle.Property.NewKeyword("fixme:video:codec", tokens [1])); break; case "TOTEM_INFO_FPS": AddProperty(Beagle.Property.NewUnsearched("fixme:video:fps", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_VIDEO_BITRATE": AddProperty(Beagle.Property.NewUnsearched("fixme:video:bitrate", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_HAS_AUDIO": break; case "TOTEM_INFO_AUDIO_BITRATE": AddProperty(Beagle.Property.NewUnsearched("fixme:audio:bitrate", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_AUDIO_CODEC": AddProperty(Beagle.Property.NewKeyword("fixme:audio:codec", tokens [1])); break; case "TOTEM_INFO_AUDIO_SAMPLE_RATE": AddProperty(Beagle.Property.NewUnsearched("fixme:audio:samplerate", Convert.ToInt32(tokens [1]))); break; case "TOTEM_INFO_AUDIO_CHANNELS": //FIXME this is very broken, needs fixing in Totem break; default: // Mismatching version of Totem with more information, possibly break; } } pout.Close(); pc.Close(); Finished(); }
protected override void DoPull() { ExternalFilterInfo efi = GetFilterInfo(this.Extension, this.MimeType); if (efi == null) { Logger.Log.Warn("Unable to find a match for extension {0}, mime type {1} when one should have matched", this.Extension, this.MimeType); Error(); } // FIXME: Need to deal with quotation marks in the XML file, probably. string[] tmp_argv = efi.Arguments.Split(' '); string[] argv = new string [tmp_argv.Length + 1]; argv [0] = efi.Command; int j = 1; for (int i = 0; i < tmp_argv.Length; i++) { if (tmp_argv [i] == String.Empty) { continue; } if (tmp_argv [i] == "%s") { argv [j] = FileInfo.FullName; } else { argv [j] = tmp_argv [i]; } j++; } SafeProcess pc = new SafeProcess(); pc.Arguments = argv; pc.RedirectStandardOutput = true; pc.UseLangC = true; // Let the external filter run for 2 minutes, max. pc.CpuLimit = 120; try { pc.Start(); } catch (SafeProcessException e) { Log.Warn(e.Message); Error(); return; } StreamReader pout = new StreamReader(pc.StandardOutput); string str; while ((str = pout.ReadLine()) != null) { AppendText(str); AppendStructuralBreak(); } pout.Close(); pc.Close(); Finished(); }
public void DoQuery(Query query, IQueryResult result, IQueryableChangeData data) { string search = null; foreach (QueryPart qp in query.Parts) { if (qp is QueryPart_Text) { search = ((QueryPart_Text)qp).Text; break; } } if (String.IsNullOrEmpty(search)) { return; } SafeProcess pc = new SafeProcess(); // Double the max-hits since it is hard to tell locate to ignore // hidden files and directories; so we prune them later. // So if hidden files are returned first, you are doomed pc.Arguments = new string[] { "locate", "-P", "-e", "-l", (2 * query.MaxHits).ToString(), search }; pc.RedirectStandardOutput = true; pc.RedirectStandardError = false; pc.UseLangC = true; try { pc.Start(); } catch (Beagle.Util.SafeProcessException e) { Log.Error(e, "Error while running 'locate -P -e -l {0} {1}'", (2 * query.MaxHits), search); return; } string match = null; ArrayList result_batch = new ArrayList(); const int MAX_QUEUED_HITS = 25; Hit hit; int count = 0; using (StreamReader pout = new StreamReader(pc.StandardOutput)) { while (count < query.MaxHits && !pout.EndOfStream) { match = pout.ReadLine(); hit = PathToHit(match); if (hit == null) { continue; } result_batch.Add(hit); if (result_batch.Count >= MAX_QUEUED_HITS) { result.Add(result_batch); result_batch.Clear(); } count++; } } result.Add(result_batch, count); pc.Close(); }
static void LaunchHelper() { // If we are in the process of shutting down, return immediately. if (Shutdown.ShutdownRequested) { return; } lock (helper_lock) { // If a helper appears to be running, return immediately. if (CheckHelper()) { return; } Logger.Log.Debug("Launching helper process"); SafeProcess p = new SafeProcess(); string[] args = new string [3]; args [0] = helper_path; if (BeagleDaemon.DisableTextCache) { args [1] = "--disable-text-cache"; } else { args [1] = String.Empty; } if (Log.Level == LogLevel.Debug) { args [2] = "--debug"; } else { args [2] = String.Empty; } p.Arguments = args; p.RedirectStandardOutput = false; p.RedirectStandardError = false; p.Start(); Logger.Log.Debug("IndexHelper PID is {0}", p.Id); // Poll the helper's socket. Wait up to a minute // (500 ms * 120 times) for the helper to be ready // to handle requests. Stopwatch watch = new Stopwatch(); watch.Start(); int poll_count = 0; bool found_helper; do { Thread.Sleep(500); ++poll_count; found_helper = CheckHelper(); } while (poll_count < 120 && !found_helper && !Shutdown.ShutdownRequested); watch.Stop(); if (!found_helper) { throw new Exception(String.Format("Couldn't launch helper process {0}", p.Id)); } Logger.Log.Debug("Found IndexHelper ({0}) in {1}", p.Id, watch); helper_pid = p.Id; } }