From aa24eddae8f54109dc50bcf968ccbc9a9ed1bb53 Mon Sep 17 00:00:00 2001 From: guo Date: Mon, 6 Mar 2023 21:55:09 +0800 Subject: [PATCH] [package]use utf-8 open file. (#197) * [package]use utf-8 open file. * add pkgs.ps1 * [powershell] add pkgs cmd support * [powershell] support download git. --- install_windows.ps1 | 13 ++++++++++++- package.py | 4 ++-- pkgs.ps1 | 1 + touch_env.ps1 | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 pkgs.ps1 diff --git a/install_windows.ps1 b/install_windows.ps1 index dd776a6..eeb0e0a 100644 --- a/install_windows.ps1 +++ b/install_windows.ps1 @@ -28,11 +28,22 @@ if (!$?) { exit } - +$git_url = "https://github.com/git-for-windows/git/releases/download/v2.39.2.windows.1/Git-2.39.2-64-bit.exe" +if ($args[0] -eq "--gitee") { + $git_url = "https://registry.npmmirror.com/-/binary/git-for-windows/v2.39.2.windows.1/Git-2.39.2-64-bit.exe" +} if (!(Test-Command git)) { echo "Git not installed. Will install Git." echo "Installing git." winget install --id Git.Git -e --source winget + if (!$?) { + echo "Can't find winget cmd, Will install git 2.39.2." + echo "downloading git." + wget -O Git64.exe $git_url + echo "Please install git. when install done, close the current terminal and run this script again." + cmd /c Git64.exe /quiet PrependPath=1 + exit + } } $PIP_SOURCE = "https://pypi.org/simple" diff --git a/package.py b/package.py index f5c22f8..4757ba7 100644 --- a/package.py +++ b/package.py @@ -130,12 +130,12 @@ Return('group') ''' - +import codecs class PackageOperation: pkg = None def parse(self, filename): - with open(filename, "r") as f: + with codecs.open(filename, "r", encoding='utf-8') as f: json_str = f.read() if json_str: diff --git a/pkgs.ps1 b/pkgs.ps1 new file mode 100644 index 0000000..83c8508 --- /dev/null +++ b/pkgs.ps1 @@ -0,0 +1 @@ +python $HOME/.env/tools/scripts/env.py package $args \ No newline at end of file diff --git a/touch_env.ps1 b/touch_env.ps1 index 55b7903..d47a8aa 100644 --- a/touch_env.ps1 +++ b/touch_env.ps1 @@ -22,4 +22,5 @@ if (!(Test-Path -Path $env_dir)) { echo 'source "$PKGS_DIR/packages/Kconfig"' | Out-File -FilePath $env_dir/packages/Kconfig -Encoding ASCII git clone $ENV_URL $env_dir/tools/scripts echo '$env:path="$HOME\.env\tools\scripts;$env:path"' > $env_dir/env.ps1 + echo '$env:pathext=".PS1;$env:pathext"' >> $env_dir/env.ps1 } \ No newline at end of file