public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH offline-mirror] use IsTerminal whenever possible
@ 2023-11-17 13:37 Maximiliano Sandoval R
  2024-01-09  8:20 ` [pbs-devel] applied: " Fabian Grünbichler
  0 siblings, 1 reply; 2+ messages in thread
From: Maximiliano Sandoval R @ 2023-11-17 13:37 UTC (permalink / raw)
  To: pbs-devel

Continuation of https://lists.proxmox.com/pipermail/pbs-devel/2023-November/007078.html.

Signed-off-by: Maximiliano Sandoval R <m.sandoval@proxmox.com>
---
 src/bin/proxmox-offline-mirror-helper.rs | 5 +++--
 src/bin/proxmox-offline-mirror.rs        | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/bin/proxmox-offline-mirror-helper.rs b/src/bin/proxmox-offline-mirror-helper.rs
index e62206c..69563ca 100644
--- a/src/bin/proxmox-offline-mirror-helper.rs
+++ b/src/bin/proxmox-offline-mirror-helper.rs
@@ -1,3 +1,4 @@
+use std::io::IsTerminal;
 use std::path::PathBuf;
 use std::process::Command;
 use std::{collections::HashMap, path::Path};
@@ -7,8 +8,8 @@ use anyhow::{bail, format_err, Error};
 use proxmox_offline_mirror::types::{ProductType, Snapshot};
 use proxmox_subscription::SubscriptionInfo;
 use proxmox_sys::command::run_command;
+use proxmox_sys::fs::file_get_contents;
 use proxmox_sys::fs::{replace_file, CreateOptions};
-use proxmox_sys::{fs::file_get_contents, linux::tty};
 use proxmox_time::epoch_to_rfc3339_utc;
 use serde_json::Value;
 
@@ -63,7 +64,7 @@ fn set_subscription_key(
 )]
 /// Interactive setup wizard.
 async fn setup(_param: Value) -> Result<(), Error> {
-    if !tty::stdin_isatty() {
+    if !std::io::stdin().is_terminal() {
         bail!("Setup wizard can only run interactively.");
     }
 
diff --git a/src/bin/proxmox-offline-mirror.rs b/src/bin/proxmox-offline-mirror.rs
index 9d37ea6..6e6a2a5 100644
--- a/src/bin/proxmox-offline-mirror.rs
+++ b/src/bin/proxmox-offline-mirror.rs
@@ -1,4 +1,5 @@
 use std::fmt::Display;
+use std::io::IsTerminal;
 use std::matches;
 use std::path::Path;
 
@@ -10,7 +11,6 @@ use serde_json::Value;
 use proxmox_router::cli::{run_cli_command, CliCommand, CliCommandMap, CliEnvironment};
 use proxmox_schema::api;
 use proxmox_section_config::SectionConfigData;
-use proxmox_sys::linux::tty;
 
 use proxmox_offline_mirror::helpers::tty::{
     read_bool_from_tty, read_selection_from_tty, read_string_from_tty,
@@ -778,7 +778,7 @@ fn action_add_key(config: &SectionConfigData) -> Result<SubscriptionKey, Error>
 )]
 /// Interactive setup wizard.
 async fn setup(config: Option<String>, _param: Value) -> Result<(), Error> {
-    if !tty::stdin_isatty() {
+    if !std::io::stdin().is_terminal() {
         bail!("Setup wizard can only run interactively.");
     }
 
-- 
2.39.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH offline-mirror] use IsTerminal whenever possible
  2023-11-17 13:37 [pbs-devel] [PATCH offline-mirror] use IsTerminal whenever possible Maximiliano Sandoval R
@ 2024-01-09  8:20 ` Fabian Grünbichler
  0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2024-01-09  8:20 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion

with slight context adaptation

On November 17, 2023 2:37 pm, Maximiliano Sandoval R wrote:
> Continuation of https://lists.proxmox.com/pipermail/pbs-devel/2023-November/007078.html.
> 
> Signed-off-by: Maximiliano Sandoval R <m.sandoval@proxmox.com>
> ---
>  src/bin/proxmox-offline-mirror-helper.rs | 5 +++--
>  src/bin/proxmox-offline-mirror.rs        | 4 ++--
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/bin/proxmox-offline-mirror-helper.rs b/src/bin/proxmox-offline-mirror-helper.rs
> index e62206c..69563ca 100644
> --- a/src/bin/proxmox-offline-mirror-helper.rs
> +++ b/src/bin/proxmox-offline-mirror-helper.rs
> @@ -1,3 +1,4 @@
> +use std::io::IsTerminal;
>  use std::path::PathBuf;
>  use std::process::Command;
>  use std::{collections::HashMap, path::Path};
> @@ -7,8 +8,8 @@ use anyhow::{bail, format_err, Error};
>  use proxmox_offline_mirror::types::{ProductType, Snapshot};
>  use proxmox_subscription::SubscriptionInfo;
>  use proxmox_sys::command::run_command;
> +use proxmox_sys::fs::file_get_contents;
>  use proxmox_sys::fs::{replace_file, CreateOptions};
> -use proxmox_sys::{fs::file_get_contents, linux::tty};
>  use proxmox_time::epoch_to_rfc3339_utc;
>  use serde_json::Value;
>  
> @@ -63,7 +64,7 @@ fn set_subscription_key(
>  )]
>  /// Interactive setup wizard.
>  async fn setup(_param: Value) -> Result<(), Error> {
> -    if !tty::stdin_isatty() {
> +    if !std::io::stdin().is_terminal() {
>          bail!("Setup wizard can only run interactively.");
>      }
>  
> diff --git a/src/bin/proxmox-offline-mirror.rs b/src/bin/proxmox-offline-mirror.rs
> index 9d37ea6..6e6a2a5 100644
> --- a/src/bin/proxmox-offline-mirror.rs
> +++ b/src/bin/proxmox-offline-mirror.rs
> @@ -1,4 +1,5 @@
>  use std::fmt::Display;
> +use std::io::IsTerminal;
>  use std::matches;
>  use std::path::Path;
>  
> @@ -10,7 +11,6 @@ use serde_json::Value;
>  use proxmox_router::cli::{run_cli_command, CliCommand, CliCommandMap, CliEnvironment};
>  use proxmox_schema::api;
>  use proxmox_section_config::SectionConfigData;
> -use proxmox_sys::linux::tty;
>  
>  use proxmox_offline_mirror::helpers::tty::{
>      read_bool_from_tty, read_selection_from_tty, read_string_from_tty,
> @@ -778,7 +778,7 @@ fn action_add_key(config: &SectionConfigData) -> Result<SubscriptionKey, Error>
>  )]
>  /// Interactive setup wizard.
>  async fn setup(config: Option<String>, _param: Value) -> Result<(), Error> {
> -    if !tty::stdin_isatty() {
> +    if !std::io::stdin().is_terminal() {
>          bail!("Setup wizard can only run interactively.");
>      }
>  
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-09  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-17 13:37 [pbs-devel] [PATCH offline-mirror] use IsTerminal whenever possible Maximiliano Sandoval R
2024-01-09  8:20 ` [pbs-devel] applied: " Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal