pyunilogs 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -503,7 +503,7 @@ dependencies = [
503
503
 
504
504
  [[package]]
505
505
  name = "pyunilogs"
506
- version = "0.1.0"
506
+ version = "0.2.0"
507
507
  dependencies = [
508
508
  "clap",
509
509
  "log",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "pyunilogs"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  edition = "2021"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyunilogs
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -1,4 +1,7 @@
1
+ use std::panic;
2
+
1
3
  use macos_unifiedlogs::unified_log;
4
+ use pyo3::exceptions::PyRuntimeError;
2
5
  use pyo3::prelude::*;
3
6
 
4
7
  mod example;
@@ -52,15 +55,25 @@ impl LogData {
52
55
 
53
56
  #[pyfunction]
54
57
  fn extract_logarchive(input_path: String) -> PyResult<Vec<LogData>> {
55
- let mut results = example::parse_log_archive(&input_path);
58
+ let final_result = panic::catch_unwind(|| {
59
+ let mut results = example::parse_log_archive(&input_path);
56
60
 
57
- let mut list = Vec::new();
61
+ let mut list = Vec::new();
58
62
 
59
- for entry in results.drain(..) {
60
- list.push(LogData::from_logdata(&entry))
61
- }
63
+ for entry in results.drain(..) {
64
+ list.push(LogData::from_logdata(&entry))
65
+ }
66
+ return list;
67
+ });
62
68
 
63
- return Ok(list);
69
+ if final_result.is_err() {
70
+ // quick and dirty catch the panics
71
+ return Err(PyRuntimeError::new_err(
72
+ "Error extracting logs with pyunilogs",
73
+ ));
74
+ } else {
75
+ return Ok(final_result.unwrap());
76
+ }
64
77
  }
65
78
 
66
79
  /// A Python module implemented in Rust.
File without changes
File without changes
File without changes
File without changes