Skip to content

Commit

Permalink
- Use proxy server settings of Windows automatically and specifying t…
Browse files Browse the repository at this point in the history
…hem by editing this script is no longer needed.

- Note that pip 20.3 or later raises an error "ValueError: check_hostname requires server_hostname" when proxy server is used.
  Downgrading pip to 20.2.4 with "py -3 -m pip install pip==20.2.4" can avoid the error.
  Relating issue: pypa/pip#9972
  • Loading branch information
nmantani committed Jun 6, 2021
1 parent 436448b commit 3450de9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
5 changes: 3 additions & 2 deletions INSTALL.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
powershell -exec bypass -command "IEX((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1'))"
```

HTTP プロキシをお使いの場合は install.ps1 をダウンロードして、ファイル中の $PROXY_HOST と
$PROXY_PORT の変数を編集してから以下のコマンドを実行してください。
ローカルに保存した install.ps1 を実行したい場合は
[install.ps1](https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1)
をダウンロードしてから以下のコマンドを実行してください。

```
powershell -exec bypass .\install.ps1
Expand Down
3 changes: 1 addition & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Please execute the following command. The latest release version of FileInsight-
powershell -exec bypass -command "IEX((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1'))"
```

If you use a HTTP proxy, please download install.ps1 and edit $PROXY_HOST and $PROXY_PORT variables in it,
then please execute the following command.
If you would like to execute locally saved install.ps1, please download [install.ps1](https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1) and execute the following command.

```
powershell -exec bypass .\install.ps1
Expand Down
5 changes: 3 additions & 2 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ FileInsight-plugins は McAfee FileInsight バイナリエディタ用のプラ
powershell -exec bypass -command "IEX((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1'))"
```

HTTP プロキシをお使いの場合は [install.ps1](https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1) をダウンロードして、ファイル中の $PROXY_HOST と
$PROXY_PORT の変数を編集してから以下のコマンドを実行してください。
ローカルに保存した install.ps1 を実行したい場合は
[install.ps1](https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1)
をダウンロードしてから以下のコマンドを実行してください。

```
powershell -exec bypass .\install.ps1
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ Please execute the following command. The latest release version of FileInsight-
powershell -exec bypass -command "IEX((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1'))"
```

If you use an HTTP proxy, please download [install.ps1](https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1) and edit $PROXY_HOST and $PROXY_PORT variables in it,
then please execute the following command.
If you would like to execute locally saved install.ps1, please download [install.ps1](https://raw.githubusercontent.com/nmantani/FileInsight-plugins/master/install.ps1) and execute the following command.

```
powershell -exec bypass .\install.ps1
Expand Down
40 changes: 25 additions & 15 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,9 @@
# powershell -exec bypass .\install.ps1 -update -snapshot
#

# Please edit these variables if you use a HTTP proxy server
$PROXY_HOST = "" # example: 10.0.0.1
$PROXY_PORT = "" # example: 8080

if ($PROXY_HOST -and $PROXY_PORT) {
$PROXY_URL = "http://${PROXY_HOST}:${PROXY_PORT}"
}
# This script automatically uses proxy server settings of Windows and you no longer need to manually specify them.
# $PROXY_HOST = "" # example: 10.0.0.1
# $PROXY_PORT = "" # example: 8080

$RELEASE_VERSION = "2.12"
$PYTHON_EXE = "C:\Windows\py.exe"
Expand All @@ -68,6 +64,18 @@ $APLIB_HASH = "C35C6D3D96CCA8A29FA863EFB22FA2E9E03F5BC2C0293C3256D7AF2E112583B3"
$EXIFTOOL_HASH = "14D5D62FA1B2147E06D8D83B3CCBC828C478D2022248DE0B0F1D7CC2C4A2C387"
$QUICKLZ_HASH = "C64082498113C220142079B6340BCE3A7B729AD550FCF7D38E08CF8BB2634A28"

function get_proxy_url {
$settings = Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' | Select-Object ProxyServer, ProxyEnable

if ($settings.ProxyServer -and $settings.ProxyEnable) {
if ($settings.ProxyServer -ilike "*=*") {
return ($settings.ProxyServer -replace "=","://" -split(';') | Select-Object -First 1)
} else {
return ("http://" + $settings.ProxyServer)
}
}
}

function create_working_directory {
.{ # Only $temp_dir is used as return value
if ((Get-Host).Version.Major -ge 5) {
Expand Down Expand Up @@ -355,11 +363,11 @@ function install_python3($work_dir) {
Write-Host "$PYTHON_EXE -3 -m ensurepip"
Invoke-Expression "$PYTHON_EXE -3 -m ensurepip"

if ($PROXY_HOST -and $PROXY_PORT) {
if ($PROXY_URL) {
Write-Host "[+] Done."
Write-Host "[+] Updating pip for Python 3..."
Write-Host "$PYTHON_EXE -3 -m pip --proxy ${PROXY_URL} install --upgrade pip"
Invoke-Expression "$PYTHON_EXE -3 -m pip --proxy ${PROXY_URL} install --upgrade pip"
Write-Host "$PYTHON_EXE -3 -m pip install --proxy ${PROXY_URL} --upgrade pip"
Invoke-Expression "$PYTHON_EXE -3 -m pip install --proxy ${PROXY_URL} --upgrade pip"
} else {
Write-Host "[+] Done."
Write-Host "[+] Updating pip for Python 3..."
Expand All @@ -385,7 +393,7 @@ function install_with_pip($name, $update) {
$upgrade_opt = ""
}

if ($PROXY_HOST -and $PROXY_PORT) {
if ($PROXY_URL) {
Write-Host "$PYTHON_EXE -3 -m pip install --proxy ${PROXY_URL} $upgrade_opt $name"
Invoke-Expression "$PYTHON_EXE -3 -m pip install --proxy ${PROXY_URL} $upgrade_opt $name"
} else {
Expand Down Expand Up @@ -807,12 +815,14 @@ function migrate_plugin_config() {
#
Write-Host "[+] FileInsight-plugins installation script"
Write-Host ""
if ($PROXY_HOST -and $PROXY_PORT) {

$PROXY_URL = get_proxy_url

if ($PROXY_URL) {
Write-Host "[+] Using HTTP proxy: $PROXY_URL"
} else {
Write-Host '[*] NOTE: If you use a HTTP proxy server, please edit $PROXY_HOST and $PROXY_PORT variables in this script.'
Write-Host ""
}
Write-Host ""

$work_dir = create_working_directory

if ($Args[0] -eq "-update") {
Expand Down

0 comments on commit 3450de9

Please sign in to comment.