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); }
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(); }
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); } }
public static SafeProcess GetClientProcess(Beagle.Hit hit) { string client = null; SafeProcess p = null; if (hit.ParentUri != null) { client = Utils.GetFirstPropertyOfParent(hit, "fixme:client"); } else { client = hit.GetFirstProperty("fixme:client"); } if (client == "evolution") { p = new SafeProcess(); p.Arguments = new string [2]; p.Arguments [0] = "evolution"; p.Arguments [1] = (hit.ParentUri != null ? hit.EscapedParentUri : hit.EscapedUri); } #if ENABLE_THUNDERBIRD else if (client == "thunderbird") { p = Thunderbird.GetSafeProcess("-viewbeagle", hit.GetFirstProperty("fixme:uri")); } #endif return(p); }
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 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 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); } }
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 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 = new SafeProcess(); p.Arguments = new string [] { "evolution", Hit.EscapedUri }; try { p.Start(); } catch (SafeProcessException e) { Console.WriteLine(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); } }
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 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); } }
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); }
// 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); } }
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(); }
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); }
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); } }
public static SafeProcess GetClientProcess(string client, string uri) { SafeProcess p = null; if (client == "evolution" || (client == null && uri.StartsWith("contacts:"))) { p = new SafeProcess(); p.Arguments = new string [2]; p.Arguments [0] = "evolution"; p.Arguments [1] = uri; } else if (client == "thunderbird") { p = new SafeProcess(); p.Arguments = new string [4]; p.Arguments [0] = "beagle-contactviewer"; p.Arguments [1] = "--manager"; p.Arguments [2] = "Thunderbird"; p.Arguments [3] = uri; } return(p); }
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 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(); }