mirror of
https://github.com/RubyMetric/chsrc
synced 2025-10-10 22:53:29 +08:00
增加 chsrc_run_directly()
并修复 pip
在 get
时在 Windows 上找不到路径的问题
[GitHub #286]
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
|
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
|
||||||
* |
|
* |
|
||||||
* Created On : <2023-08-29>
|
* Created On : <2023-08-29>
|
||||||
* Last Modified : <2025-08-27>
|
* Last Modified : <2025-09-12>
|
||||||
*
|
*
|
||||||
* chsrc framework
|
* chsrc framework
|
||||||
* ------------------------------------------------------------*/
|
* ------------------------------------------------------------*/
|
||||||
@@ -1348,6 +1348,28 @@ chsrc_run_as_a_service (const char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 以纯粹的方式直接运行命令,不做任何多余处理,
|
||||||
|
* 命令执行前显示给用户,并保留所有输出给用户
|
||||||
|
*
|
||||||
|
* @return 返回命令的退出状态
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
chsrc_run_directly (const char *cmd)
|
||||||
|
{
|
||||||
|
if (ENGLISH)
|
||||||
|
xy_log_brkt (blue (App_Name), bdblue ("RUN"), blue (cmd));
|
||||||
|
else
|
||||||
|
xy_log_brkt (blue (App_Name), bdblue ("运行"), blue (cmd));
|
||||||
|
|
||||||
|
if (in_dry_run_mode())
|
||||||
|
{
|
||||||
|
return 0; // Dry Run 此时立即结束,并不真正执行
|
||||||
|
}
|
||||||
|
int status = system (cmd);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 在本目录创建一个临时文件
|
* @brief 在本目录创建一个临时文件
|
||||||
|
@@ -10,7 +10,7 @@ pl_python_pip_prelude (void)
|
|||||||
chef_prep_this (pl_python_pip, gsr);
|
chef_prep_this (pl_python_pip, gsr);
|
||||||
|
|
||||||
chef_set_created_on (this, "2023-09-03");
|
chef_set_created_on (this, "2023-09-03");
|
||||||
chef_set_last_updated (this, "2025-09-10");
|
chef_set_last_updated (this, "2025-09-12");
|
||||||
chef_set_sources_last_updated (this, "2025-07-11");
|
chef_set_sources_last_updated (this, "2025-07-11");
|
||||||
|
|
||||||
chef_set_chef (this, NULL);
|
chef_set_chef (this, NULL);
|
||||||
@@ -31,12 +31,13 @@ pl_python_pip_getsrc (char *option)
|
|||||||
char *py_prog_name = NULL;
|
char *py_prog_name = NULL;
|
||||||
pl_python_get_py_program_name (&py_prog_name);
|
pl_python_get_py_program_name (&py_prog_name);
|
||||||
|
|
||||||
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url 2>/dev/null");
|
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url");
|
||||||
|
|
||||||
int status = system (cmd);
|
int status = chsrc_run_directly (cmd);
|
||||||
if (0 == status)
|
if (0 == status)
|
||||||
{
|
{
|
||||||
// 执行成功时显示当前源
|
// 执行成功时显示当前源
|
||||||
|
xy_noop ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -47,7 +48,7 @@ pl_python_pip_getsrc (char *option)
|
|||||||
chsrc_note2 ("pip 中未配置源,显示默认上游源:");
|
chsrc_note2 ("pip 中未配置源,显示默认上游源:");
|
||||||
|
|
||||||
Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream");
|
Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream");
|
||||||
chsrc_log (default_source.url);
|
say (default_source.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user