问:
Blazor wasm - JSInterop fails on first run
I'm very new to Blazor and I'm trying basic and simple things...
in the "default" new wasm project (VS2022, target fwk 6.0), I added some rows to the FetchData.razor table in order to have the Vscroll bar visible...

I'd like to have a sticky button to test a "go top" to the page via java script..
I added a wwwroot\Scripts\myJs.js file including a simple

```<code>function scrollToTop() {
document.documentElement.scrollTop = 0;
}
</code>```

and added reference to the file in index.html,

```<code><script src="_framework/blazor.webassembly.js"></script>
<script src="Scripts/myJs.js"></script>
</code>```

FetchData.razor markup includes now my call to JsInterop like

```<code>@page "/fetchdata"
@using BlazorApp5.Shared
@inject HttpClient Http
@inject IJSRuntime JSRuntime

...
<button @onclick="OnGoTopClick" type="button" class="btn-sm btn-group-sm" style="bottom:20px; right:20px; position:fixed; z-index:9000;">Go Top</button>

@code{
...
    private async void OnGoTopClick()
    {
        await JSRuntime.InvokeVoidAsync("scrollToTop");
    }
}
</code>```

but it always fails "on first run", reporting Microsoft.JSInterop.JSException: Could not find 'scrollToTop' ('scrollToTop' was undefined).
When "reloading" the page, the js function is correctly executed without problems...

VS 2022, a .Net6 wasm prj

can you please provide a hint to check/solve?

TIA

Andrea

Body:
I'm very new to Blazor and I'm trying basic and simple things...
in the "default" new wasm project (VS2022, target fwk 6.0), I added some rows to the FetchData.razor table in order to have the Vscroll bar visible...

I'd like to have a sticky button to test a "go top" to the page via java script..
I added a wwwroot\Scripts\myJs.js file including a simple

function scrollToTop() {
document.documentElement.scrollTop = 0;
}

and added reference to the file in index.html,

FetchData.razor markup includes now my call to JsInterop like

@page "/fetchdata"
@using BlazorApp5.Shared
@inject HttpClient Http
@inject IJSRuntime JSRuntime

...
<button @onclick="OnGoTopClick" type="button" class="btn-sm btn-group-sm" style="bottom:20px; right:20px; position:fixed; z-index:9000;">Go Top</button>

@code{
...
    private async void OnGoTopClick()
    {
        await JSRuntime.InvokeVoidAsync("scrollToTop");
    }
}

but it always fails "on first run", reporting Microsoft.JSInterop.JSException: Could not find 'scrollToTop' ('scrollToTop' was undefined).
When "reloading" the page, the js function is correctly executed without problems...

VS 2022, a .Net6 wasm prj

can you please provide a hint to check/solve?

TIA

Andrea


来源: stackexchange

问:
How to make correct Selenium script to put for CircleCI?
I'm so far learning CircleCI builds and things and this is just a test/example to practice. I have a example test_page.py file with some Selenium (python) code. It uses chromedriver, and, what's important (I guess), this script has something like that:

```<code>s=Service('C:\Program Files\chromedriver.exe')
browser = webdriver.Chrome(service=s)
</code>```

It looks like that, because without these lines my test code didn't execute. After some time I managed to put correct config.yml for this script, too. Now I know that (most likely) everything is okay - it upgrades pip, installs dependencies without errors etc. but now is problem with executing this test_page.py - because of these 2 lines above, I guess. Below is full error report from CircleCI:

And below is my config.yml file if it's needed. I was trying with circleci's orb for browsers from:  https://circleci.com/developer/orbs/orb/circleci/browser-tools  But I'd have no idea where could it install - so I could change this s=Service('C:\Program Files\chromedriver.exe') . Could it work with /usr/local/bin/chromedriver.exe?

```<code>version: 2.1
jobs:
  build:
    docker:
      - image: circleci/python:3.8
      - image: selenium/standalone-chrome:3.11.0
    steps:
      - checkout
      - run:
          name: Upgrade pip
          command: |
            pip install --upgrade pip
      - run:
          name: Install Dependencies
          command: |
            pip install -r requirements.txt
      - run:
          name: Run Selenium Tests
          command: |
            python -m pytest test_page.py
</code>```

How should I change my config.yml OR test_page.py code to make it viable for circleci?

EDIT:
I added chromedriver-py to my requirements.txt file, so one error disappeared - I guess here's problem with something different:

```<code>    raise KeyError(key) from None
E   KeyError: 'DISPLAY'
</code>```

So now it looks like this:

EDIT2: looks like it was pyautogui's fault, I removed it from my code, but now chromedriver's path is still wrong... I changed path, but error (look below) appears. WHERE should I put chromedriver's path? And can I make it work with pyautogui?

```<code>ERROR test_page.py - selenium.common.exceptions.WebDriverException: Message: Service /usr/local/bin/chromedriver.exe unexpectedly exited. Status code was: 127
</code>```

And below errors in circleci - with pyautogui removed and s=Service set to: s=Service('/usr/local/bin/chromedriver.exe')

Without s=Service and with just browser = webdriver.Chrome()

```<code>============================= test session starts ==============================
platform linux -- Python 3.8.12, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/circleci/project
collecting ...
collecting 0 items / 1 error
collected 0 items / 1 error

==================================== ERRORS ====================================
________________________ ERROR collecting test_page.py _________________________
test_page.py:14: in <module>
    browser = webdriver.Chrome()
../.local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py:81: in __init__
    super().__init__(
../.local/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py:103: in __init__
    self.service.start()
../.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py:106: in start
    self.assert_process_still_running()
../.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py:119: in assert_process_still_running
    raise WebDriverException(f"Service {self.path} unexpectedly exited. Status code was: {return_code}")
E   selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
=========================== short test summary info ============================
ERROR test_page.py - selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.85s ===============================

Exited with code exit status 2
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm so far learning CircleCI builds and things and this is just a test/example to practice. I have a example test_page.py file with some Selenium (python) code. It uses chromedriver, and, what's important (I guess), this script has something like that:

s=Service('C:\Program Files\chromedriver.exe')
browser = webdriver.Chrome(service=s)

It looks like that, because without these lines my test code didn't execute. After some time I managed to put correct config.yml for this script, too. Now I know that (most likely) everything is okay - it upgrades pip, installs dependencies without errors etc. but now is problem with executing this test_page.py - because of these 2 lines above, I guess. Below is full error report from CircleCI:

And below is my config.yml file if it's needed. I was trying with circleci's orb for browsers from:  https://circleci.com/developer/orbs/orb/circleci/browser-tools  But I'd have no idea where could it install - so I could change this s=Service('C:\Program Files\chromedriver.exe') . Could it work with /usr/local/bin/chromedriver.exe?

version: 2.1
jobs:
  build:
    docker:
      - image: circleci/python:3.8
      - image: selenium/standalone-chrome:3.11.0
    steps:
      - checkout
      - run:
          name: Upgrade pip
          command: |
            pip install --upgrade pip
      - run:
          name: Install Dependencies
          command: |
            pip install -r requirements.txt
      - run:
          name: Run Selenium Tests
          command: |
            python -m pytest test_page.py

How should I change my config.yml OR test_page.py code to make it viable for circleci?

EDIT:
I added chromedriver-py to my requirements.txt file, so one error disappeared - I guess here's problem with something different:

    raise KeyError(key) from None
E   KeyError: 'DISPLAY'

So now it looks like this:

EDIT2: looks like it was pyautogui's fault, I removed it from my code, but now chromedriver's path is still wrong... I changed path, but error (look below) appears. WHERE should I put chromedriver's path? And can I make it work with pyautogui?

ERROR test_page.py - selenium.common.exceptions.WebDriverException: Message: Service /usr/local/bin/chromedriver.exe unexpectedly exited. Status code was: 127

And below errors in circleci - with pyautogui removed and s=Service set to: s=Service('/usr/local/bin/chromedriver.exe')

Without s=Service and with just browser = webdriver.Chrome()

============================= test session starts ==============================
platform linux -- Python 3.8.12, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/circleci/project
collecting ...
collecting 0 items / 1 error
collected 0 items / 1 error

==================================== ERRORS ====================================
________________________ ERROR collecting test_page.py _________________________
test_page.py:14: in <module>
    browser = webdriver.Chrome()
../.local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py:81: in __init__
    super().__init__(
../.local/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py:103: in __init__
    self.service.start()
../.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py:106: in start
    self.assert_process_still_running()
../.local/lib/python3.8/site-packages/selenium/webdriver/common/service.py:119: in assert_process_still_running
    raise WebDriverException(f"Service {self.path} unexpectedly exited. Status code was: {return_code}")
E   selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
=========================== short test summary info ============================
ERROR test_page.py - selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.85s ===============================

Exited with code exit status 2


问:
Powershell Gui Multiline TextBox to retain original cursor position after key press
I'm working on a small gui project, sending messages to Teams channel via Powershell.
I created the Gui with text box, and enabled function activation on button press.
I would like the cursor to remain at the begining of the box i.e. 0 place on first line. Haven't been able to find any solution to that. Code below. Please advise.</p>
```<code>Add-Type -AssemblyName System.Windows.Forms

Function ButtonClick
{
    $test = $textBoxDisplay.Text
    Invoke-RestMethod -Method Post -ContentType 'Application/Json' -Body "{`"text`":`"$test`"}" -Uri $myTeamsWebhook
    $textBoxDisplay.Clear()

}

$myTeamsWebhook = 'xxx'

[System.Windows.Forms.Application]::EnableVisualStyles()
$button = New-Object 'System.Windows.Forms.Button'
$button.Location = '10, 10'
$button.Name = "buttonGo"
$button.Size = '75, 25'
$button.TabIndex = 0
$button.Text = "&Go"
$button.UseVisualStyleBackColor = $true
$button.Add_Click({ButtonClick})

$textBoxDisplay = New-Object 'System.Windows.Forms.TextBox'
$textBoxDisplay.Location = '12, 50'
$textBoxDisplay.Multiline = $true
$textBoxDisplay.Name = "textBoxDisplay"
$textBoxDisplay.Size = '470, 150'
$textBoxDisplay.TabIndex = 1
$textBoxDisplay.Focus()
$textBoxDisplay.AcceptsReturn = $false
$textBoxDisplay.WordWrap = $true

$textBoxDisplay.add_KeyDown({
if ($_.KeyCode -eq "Enter"){ButtonClick}

})

$mainForm = New-Object 'System.Windows.Forms.Form'
$mainForm.Size = '500, 250'
$mainForm.Controls.Add($button)
$mainForm.Controls.Add($textBoxDisplay)
$mainForm.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$mainForm.Name = "mainForm"
$mainForm.Text = "GUI Test"

$mainForm.ShowDialog()
</code>```

Body:
I'm working on a small gui project, sending messages to Teams channel via Powershell.
I created the Gui with text box, and enabled function activation on button press.
I would like the cursor to remain at the begining of the box i.e. 0 place on first line. Haven't been able to find any solution to that. Code below. Please advise.

Add-Type -AssemblyName System.Windows.Forms

Function ButtonClick
{
    $test = $textBoxDisplay.Text
    Invoke-RestMethod -Method Post -ContentType 'Application/Json' -Body "{`"text`":`"$test`"}" -Uri $myTeamsWebhook
    $textBoxDisplay.Clear()

}

$myTeamsWebhook = 'xxx'

[System.Windows.Forms.Application]::EnableVisualStyles()
$button = New-Object 'System.Windows.Forms.Button'
$button.Location = '10, 10'
$button.Name = "buttonGo"
$button.Size = '75, 25'
$button.TabIndex = 0
$button.Text = "&Go"
$button.UseVisualStyleBackColor = $true
$button.Add_Click({ButtonClick})

$textBoxDisplay = New-Object 'System.Windows.Forms.TextBox'
$textBoxDisplay.Location = '12, 50'
$textBoxDisplay.Multiline = $true
$textBoxDisplay.Name = "textBoxDisplay"
$textBoxDisplay.Size = '470, 150'
$textBoxDisplay.TabIndex = 1
$textBoxDisplay.Focus()
$textBoxDisplay.AcceptsReturn = $false
$textBoxDisplay.WordWrap = $true

$textBoxDisplay.add_KeyDown({
if ($_.KeyCode -eq "Enter"){ButtonClick}

})

$mainForm = New-Object 'System.Windows.Forms.Form'
$mainForm.Size = '500, 250'
$mainForm.Controls.Add($button)
$mainForm.Controls.Add($textBoxDisplay)
$mainForm.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$mainForm.Name = "mainForm"
$mainForm.Text = "GUI Test"

$mainForm.ShowDialog()


问:
What happens to the Celery tasks in a queue which has no worker to process the tasks
I have a question related to Celery and your help is very much appreciated. I have a Django app and I am using celery to schedule a task once in every 10 minutes using send_task in to a redis queue for example queue1 with the expires value as 10 seconds.

And I have not assigned any worker to process the tasks from this queue. So, here the question is, does Celery automatically discards the expired tasks or they get piled up?

I tried to send the tasks once in every 10 minutes and I didn't assign any worker for that queue and now what I can see is that the tasks are getting piled up even though I mentioned the expires value 10 seconds

app.send_task( 'currentfolder.django.tasks.update_celeryq_status',
args=(queue.name,),
expires=10,
queue=queue.name,
ignore_result=True,
routing_key=queue.routing_key, )


问:
Python FFmpeg Video Streaming: how to capture multiple representations (resolutions) with webcam
I am trying to capture webcam stream and make HLS stream. I managed to create HLS stream for one Representation (only one stream resolution) but when I try to create (hls.output) more than one, I get this error:

```<code>C:\Users\ltadic\Desktop\hls stream>C:/Users/ltadic/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/ltadic/Desktop/hls stream/camera_stream.py"
ERROR:root:ffmpeg failed to execute command: b"ffmpeg version 2022-12-11-git-c3e20f78b0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers\r\n  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)\r\n
 configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint\r\n  libavutil      57. 43.100 / 57. 43.100\r\n  libavcodec     59. 55.100 / 59. 55.100\r\n  libavformat    59. 34.102 / 59. 34.102\r\n  libavdevice    59.  8.101 / 59.  8.101\r\n  libavfilter     8. 52.100 /  8. 52.100\r\n  libswscale      6.  8.112 /  6.  8.112\r\n  libswresample   4.  9.100 /  4.  9.100\r\n  libpostproc    56.  7.100 / 56.  7.100\r\nInput #0, dshow, from 'video=Fantech Luminous C30':\r\n  Duration: N/A, start: 1593.585118, bitrate: N/A\r\n  Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/bt709/unknown), 1920x1080, 25 fps, 25 tbr, 10000k tbn\r\n[dshow @ 0000018b1c4d4280] Could not run graph (sometimes caused by a device already in use by other application)\r\nvideo=Fantech Luminous C30: I/O error\r\n"
Traceback (most recent call last):
  File "c:\Users\ltadic\Desktop\hls stream\camera_stream.py", line 13, in <module>
    hls.output('C:\\Users\\ltadic\\Desktop\\camera_stream\\hls1.m3u8')
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 93, in output
    self.run(ffmpeg_bin, monitor, **options)
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 121, in run
    asyncio.run(self.async_run(ffmpeg_bin, monitor, **options))
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 112, in async_run
    self._run(ffmpeg_bin, monitor, **options)
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 106, in _run
    self.pipe, err = process.run()
</code>```

This is my code:

```<code>import ffmpeg_streaming
from ffmpeg_streaming import Formats,Bitrate, Representation, Size

video = ffmpeg_streaming.input('Fantech Luminous C30', capture = True)

_360p  = Representation(Size(640, 360), Bitrate(276 * 1024, 128 * 1024))
_480p  = Representation(Size(854, 480), Bitrate(750 * 1024, 192 * 1024))
_720p  = Representation(Size(1280, 720), Bitrate(2048 * 1024, 320 * 1024))

hls = video.hls(Formats.h264(),hls_list_size=10, hls_time=5)
hls.flags('delete_segments')
hls.representations(_360p, _480p, _720p)
hls.output('C:\\Users\\ltadic\\Desktop\\camera_stream\\hls1.m3u8')

</code>```

Body:
I am trying to capture webcam stream and make HLS stream. I managed to create HLS stream for one Representation (only one stream resolution) but when I try to create (hls.output) more than one, I get this error:

C:\Users\ltadic\Desktop\hls stream>C:/Users/ltadic/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/ltadic/Desktop/hls stream/camera_stream.py"
ERROR:root:ffmpeg failed to execute command: b"ffmpeg version 2022-12-11-git-c3e20f78b0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers\r\n  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)\r\n
 configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint\r\n  libavutil      57. 43.100 / 57. 43.100\r\n  libavcodec     59. 55.100 / 59. 55.100\r\n  libavformat    59. 34.102 / 59. 34.102\r\n  libavdevice    59.  8.101 / 59.  8.101\r\n  libavfilter     8. 52.100 /  8. 52.100\r\n  libswscale      6.  8.112 /  6.  8.112\r\n  libswresample   4.  9.100 /  4.  9.100\r\n  libpostproc    56.  7.100 / 56.  7.100\r\nInput #0, dshow, from 'video=Fantech Luminous C30':\r\n  Duration: N/A, start: 1593.585118, bitrate: N/A\r\n  Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/bt709/unknown), 1920x1080, 25 fps, 25 tbr, 10000k tbn\r\n[dshow @ 0000018b1c4d4280] Could not run graph (sometimes caused by a device already in use by other application)\r\nvideo=Fantech Luminous C30: I/O error\r\n"
Traceback (most recent call last):
  File "c:\Users\ltadic\Desktop\hls stream\camera_stream.py", line 13, in <module>
    hls.output('C:\\Users\\ltadic\\Desktop\\camera_stream\\hls1.m3u8')
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 93, in output
    self.run(ffmpeg_bin, monitor, **options)
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 121, in run
    asyncio.run(self.async_run(ffmpeg_bin, monitor, **options))
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 112, in async_run
    self._run(ffmpeg_bin, monitor, **options)
  File "C:\Users\ltadic\AppData\Local\Programs\Python\Python311\Lib\site-packages\ffmpeg_streaming\_media.py", line 106, in _run
    self.pipe, err = process.run()

This is my code:

import ffmpeg_streaming
from ffmpeg_streaming import Formats,Bitrate, Representation, Size

video = ffmpeg_streaming.input('Fantech Luminous C30', capture = True)

_360p  = Representation(Size(640, 360), Bitrate(276 * 1024, 128 * 1024))
_480p  = Representation(Size(854, 480), Bitrate(750 * 1024, 192 * 1024))
_720p  = Representation(Size(1280, 720), Bitrate(2048 * 1024, 320 * 1024))

hls = video.hls(Formats.h264(),hls_list_size=10, hls_time=5)
hls.flags('delete_segments')
hls.representations(_360p, _480p, _720p)
hls.output('C:\\Users\\ltadic\\Desktop\\camera_stream\\hls1.m3u8')


问:
How to avoid ModuleNotFoundError: No module named 'pandas' in VSCode
I'm trying to run from a tutorial in VSCode and keep getting errors about no pandas module but I know it is installed.

I've tried using "select interpreter" to swap between versions of python but then I have issues with requests module. The code below does work if I comment out the pandas module but I can't understand why this code doesn't work.

I tried using pip3 install pandas but the terminal tells me it is already installed.

The code is:

```<code>import requests
from bs4 import BeautifulSoup
import time
import datetime
import smtplib
import csv
#import pandas as pd

def check_price():

    URL = "https://www.amazon.co.uk/Funny-Data-T-shirt-Mining-T-Shirt/dp/B0B68TSGCR/ref=sr_1_1?keywords=funny+data+mining&qid=1560000000&s=gateway&sr=8-1"

    html = requests.get(URL).text

    headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"}

    page = requests.get(URL, headers=headers)
    soup1 = BeautifulSoup(page.content, "html.parser")
    soup2 = BeautifulSoup(soup1.prettify(), "html.parser")
    title = soup2.find(id="productTitle").get_text().strip()
    price_whole = soup2.find(attrs= {"class": "a-price-whole"}).get_text()
    price_fraction = soup2.find(attrs= {"class": "a-price-fraction"}).get_text()
    price = (f"{price_whole.split()[0]}.{price_fraction.split()[0]}")
    today = datetime.date.today()
    header = ['Title', 'Price', 'Date']
    data = [title, price, today]

    with open("amazonscraper2.csv", "a+", newline="", encoding="utf-8") as f:
        writer = csv.writer(f)
        writer.writerow(header)
        writer.writerow(data)

while(True):
    check_price()
    time.sleep(5)
    print("running")
    #df = pd.read_csv("amazonscraper2.csv")
    #print(df)
</code>```

Body:
I'm trying to run from a tutorial in VSCode and keep getting errors about no pandas module but I know it is installed.

I've tried using "select interpreter" to swap between versions of python but then I have issues with requests module. The code below does work if I comment out the pandas module but I can't understand why this code doesn't work.

I tried using pip3 install pandas but the terminal tells me it is already installed.

The code is:

import requests
from bs4 import BeautifulSoup
import time
import datetime
import smtplib
import csv
#import pandas as pd

def check_price():

    URL = "https://www.amazon.co.uk/Funny-Data-T-shirt-Mining-T-Shirt/dp/B0B68TSGCR/ref=sr_1_1?keywords=funny+data+mining&qid=1560000000&s=gateway&sr=8-1"

    html = requests.get(URL).text

    headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"}

    page = requests.get(URL, headers=headers)
    soup1 = BeautifulSoup(page.content, "html.parser")
    soup2 = BeautifulSoup(soup1.prettify(), "html.parser")
    title = soup2.find(id="productTitle").get_text().strip()
    price_whole = soup2.find(attrs= {"class": "a-price-whole"}).get_text()
    price_fraction = soup2.find(attrs= {"class": "a-price-fraction"}).get_text()
    price = (f"{price_whole.split()[0]}.{price_fraction.split()[0]}")
    today = datetime.date.today()
    header = ['Title', 'Price', 'Date']
    data = [title, price, today]

    with open("amazonscraper2.csv", "a+", newline="", encoding="utf-8") as f:
        writer = csv.writer(f)
        writer.writerow(header)
        writer.writerow(data)

while(True):
    check_price()
    time.sleep(5)
    print("running")
    #df = pd.read_csv("amazonscraper2.csv")
    #print(df)


问:
Barchart doesn't show my values when filtered
I don't know if I'm using the correct way of filtering a barchart, or even if my code is properly written.

But I have  problem, when I open my dashboard, I have 3 charts, one of the piecharts can filter the barchart, and depending on which was selected, the barchart only shows the piechart selected, otherwise shows all.

My problem is when I filter those, I'm getting the correct filter, but I can't get the labels to appear, they just appear when I got only one, for example if I have 1Yellow, 15 Reds, its only a bar to show, but it only shows the label for the yellow one, but if yellow2 and 15 reds, it doesn't show any of them.

It should be a easy fix, I just can't see where is the error.

```ArrayList<Integer> colors_to_add_type = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_MINOR = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_MEDIUM = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_MAJOR = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_OTHER = new ArrayList<>();
                            Iterator<String> defects_colors_keys;
                            defects_colors_keys = colors_type.keys();
                            while (defects_colors_keys.hasNext()){
                                String key = defects_colors_keys.next();
                                Log.e("COLOR_KEY", "onResponse: " + key );
                                int to_add = Color.parseColor(colors_type.getString(key));
                                int to_add_MINOR = Color.parseColor("#00FF00");
                                int to_add_MEDIUM = Color.parseColor("#FFFF00");
                                int to_add_MAJOR = Color.parseColor("#FF0000");
                                int to_add_OTHER = Color.parseColor("#800080");
                                Log.e("COLOR_NAME", "onResponse: " + colors_type.getString(key));
                                colors_to_add_type.add(to_add);
                                colors_to_add_type_MAJOR.add(to_add_MAJOR);
                                colors_to_add_type_MEDIUM.add(to_add_MEDIUM);
                                colors_to_add_type_MINOR.add(to_add_MINOR);
                                colors_to_add_type_OTHER.add(to_add_OTHER);
                            }
                            List<LegendEntry> legends_type = new ArrayList<>();
                            List<LegendEntry> legends_type_MINOR = new ArrayList<>();
                            List<LegendEntry> legends_type_MEDIUM = new ArrayList<>();
                            List<LegendEntry> legends_type_MAJOR = new ArrayList<>();
                            List<LegendEntry> legends_type_OTHER = new ArrayList<>();
                                type_of_defects = by_type.keys();
                                int c = 0;
                                if(!map_defects_by_type_count.isEmpty()){
                                    map_defects_by_type_count.clear();
                                }
                                Log.e("DEFECTS", defects_list.toString());
                                Log.e("DEFECTS",String.valueOf(defects_list.size()));
                                while(type_of_defects.hasNext()) {
                                    String key = type_of_defects.next();
                                    Log.e("DEFECTS_type", key.toString());
                                    map_defects_by_type_count.put(key, by_type.getInt(key));
                                    map_get_defect_type.put(c, key);
                                    LegendEntry legendEntry = new LegendEntry();
                                    legendEntry.label = key;
                                    legendEntry.formColor = colors_to_add_type.get(c);
                                    legends_type.add(legendEntry);
                                    arr_by_type.add(new BarEntry((float)c + 1, (int)by_type.getInt(key), (String)key));
                                    c++;
                                    for (int i = 0; i < defects_list.size(); i++){
                                        if (defects_list.get(i).getStringProperty("defect").equals(key)){
                                            if (defects_list.get(i).getStringProperty("criticality").equals("MAJOR")){
                                                arr_by_type_MAJOR.add(new BarEntry((float)c +1, (int)by_type.getInt(key), (String)key));
                                                legends_type_MAJOR.add(legendEntry);
                                                break;
                                            }
                                            if (defects_list.get(i).getStringProperty("criticality").equals("MEDIUM")){
                                                arr_by_type_MEDIUM.add(new BarEntry((float)c +1 , (int)by_type.getInt(key), (String)key));
                                                legends_type_MEDIUM.add(legendEntry);
                                                break;
                                            }
                                            if (defects_list.get(i).getStringProperty("criticality").equals("MINOR")){
                                                arr_by_type_MINOR.add(new BarEntry((float)c +1, (int)by_type.getInt(key), (String)key));
                                                legends_type_MINOR.add(legendEntry);
                                                break;
                                            }
                                            if (defects_list.get(i).getStringProperty("criticality").equals("OTHER")){
                                                arr_by_type_OTHER.add(new BarEntry((float)c +1, (int)by_type.getInt(key), (String)key));
                                                legends_type_OTHER.add(legendEntry);
                                                break;
                                            }
                                        }
                                    }
                                }
                                TOTAL_DEFECTS = TOTAL_BY_CRIT;
                            if(TOTAL_BY_CRIT != 0){
                                if(MAJOR != 0){
                                    major_percent =  (float) MAJOR / TOTAL_BY_CRIT;
                                }
                                if(MEDIUM != 0){
                                    medium_percent =  (float) MEDIUM / TOTAL_BY_CRIT;
                                }
                                if(MINOR != 0){
                                    minor_percent = (float) MINOR / TOTAL_BY_CRIT;
                                }
                                if(OTHER != 0){
                                    other_percent = (float) OTHER / TOTAL_BY_CRIT;
                                }
                            }

                            TOTAL_SOURCE = TOTAL_H_M;
                            if(TOTAL_H_M != 0){
                                if(HUMAN != 0){
                                    human_percent = (float) HUMAN / TOTAL_H_M;
                                }
                                if(MACHINE != 0){
                                    machine_percent = (float) MACHINE / TOTAL_H_M;
                                }
                            }
                            arr_by_defect.add(new PieEntry(MAJOR, "MAJOR"));
                            arr_by_defect.add(new PieEntry(MEDIUM, "MEDIUM"));
                            arr_by_defect.add(new PieEntry(MINOR, "MINOR"));
                            arr_by_defect.add(new PieEntry(OTHER, "OTHER"));
                            arr_by_source.add(new PieEntry(HUMAN, "HUMAN"));
                            arr_by_source.add(new PieEntry(MACHINE, "MACHINE"));
                            dataSet_by_defect = new PieDataSet(arr_by_defect, "");
                            dataSet_by_source = new PieDataSet(arr_by_source, "");
                            dataSet_by_type = new BarDataSet(arr_by_type, "");
                            dataSet_by_type_MAJOR = new BarDataSet(arr_by_type_MAJOR, "");
                            dataSet_by_type_MEDIUM = new BarDataSet(arr_by_type_MEDIUM, "");
                            dataSet_by_type_MINOR = new BarDataSet(arr_by_type_MINOR, "");
                            dataSet_by_type_OTHER = new BarDataSet(arr_by_type_OTHER, "");
                            //GET THE COLORS
                            String colorMajor = colors.getString("MAJOR");
                            String colorMedium = colors.getString("MEDIUM");
                            String colorMinor = colors.getString("MINOR");
                            String colorOther = colors.getString("OTHER");
                            String colorHuman = human_machine_colors.getString("human");
                            String colorMachine = human_machine_colors.getString("machine");
                            final int[] sliceColors = {Color.parseColor(colorMajor), Color.parseColor(colorMedium), Color.parseColor(colorMinor), Color.parseColor(colorOther)};
                            ArrayList<Integer> colorsSet = new ArrayList<>();
                            for (int color : sliceColors){
                                colorsSet.add(color);
                            }
                            Log.e("COLORS_TO ADD", "MAJOR" + colorMajor);
                            Log.e("COLORS_TO ADD", "MEDIUM" + colorMedium);
                            Log.e("COLORS_TO ADD", "MINOR" + colorMinor);
                            Log.e("COLORS_TO ADD", "OTHER" + colorOther);
                            dataSet_by_defect.setColors(colorsSet);
                            final int[] sliceColors_hm = {Color.parseColor(colorHuman), Color.parseColor(colorMachine)};
                            ArrayList<Integer> colorsSet_hm = new ArrayList<>();
                            for (int color : sliceColors_hm){
                                colorsSet_hm.add(color);
                            }
                            dataSet_by_source.setColors(colorsSet_hm);
                            dataSet_by_type.setColors(colors_to_add_type);
                            dataSet_by_type_MINOR.setColors(colors_to_add_type_MINOR);
                            dataSet_by_type_MEDIUM.setColors(colors_to_add_type_MEDIUM);
                            dataSet_by_type_MAJOR.setColors(colors_to_add_type_MAJOR);
                            dataSet_by_type_OTHER.setColors(colors_to_add_type_OTHER);
                            dataSet_by_type.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_MINOR.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_MEDIUM.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_MAJOR.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_OTHER.setAxisDependency(YAxis.AxisDependency.RIGHT);

                            final PieData data_defect = new PieData(dataSet_by_defect);
                            final PieData data_source = new PieData(dataSet_by_source);
                            final BarData data_type = new BarData(dataSet_by_type);
                            final BarData data_type_MINOR = new BarData(dataSet_by_type_MINOR);
                            final BarData data_type_MEDIUM = new BarData(dataSet_by_type_MEDIUM);
                            final BarData data_type_MAJOR = new BarData(dataSet_by_type_MAJOR);
                            final BarData data_type_OTHER = new BarData(dataSet_by_type_OTHER);
                            data_type.setDrawValues(true);
                            data_type_MAJOR.setDrawValues(true);
                            data_type_MEDIUM.setDrawValues(true);
                            data_type_MINOR.setDrawValues(true);
                            data_type_OTHER.setDrawValues(true);

                            data_defect.setDrawValues(false);
                            data_source.setDrawValues(false);
                            //data_type.setBarWidth(.75f);
                            piechart_defects.setDrawHoleEnabled(true);
                            piechart_defects.setHoleColor(Color.TRANSPARENT);
                            piechart_defects.setDrawEntryLabels(false);
                            piechart_defects.setDrawMarkers(false);
                            piechart_defects.setCenterText(String.valueOf(TOTAL_DEFECTS) + " TOTAL");
                            piechart_defects.setCenterTextSize(10);
                            piechart_defects.getDescription().setEnabled(false);
                            Legend l_defect = piechart_defects.getLegend();
                            l_defect.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
                            l_defect.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
                            l_defect.setOrientation(Legend.LegendOrientation.VERTICAL);
                            l_defect.setDrawInside(false);
                            l_defect.setEnabled(true);
                            l_defect.setFormSize(4f);
                            l_defect.setTextColor(Color.WHITE);
                            l_defect.setTextSize(.5f);
                            piechart_source.setDrawHoleEnabled(true);
                            piechart_source.setDrawEntryLabels(false);
                            piechart_source.setHoleColor(Color.TRANSPARENT);
                            piechart_source.setDrawMarkers(false);
                            piechart_source.setCenterText(String.valueOf(TOTAL_SOURCE) + " TOTAL");
                            piechart_source.setCenterTextSize(10);
                            piechart_source.getDescription().setEnabled(false);
                            piechart_source.setTransparentCircleRadius(10f);
                            Legend l_source = piechart_source.getLegend();
                            l_source.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
                            l_source.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
                            l_source.setOrientation(Legend.LegendOrientation.VERTICAL);
                            l_source.setDrawInside(false);
                            l_source.setEnabled(true);
                            l_source.setFormSize(4f);
                            l_source.setTextColor(Color.WHITE);
                            l_source.setTextSize(.5f);
                            dataSet_by_type.setValueTextColor(Color.WHITE);
                            dataSet_by_type_MAJOR.setValueTextColor(Color.WHITE);
                            dataSet_by_type_MEDIUM.setValueTextColor(Color.WHITE);
                            dataSet_by_type_MINOR.setValueTextColor(Color.WHITE);
                            dataSet_by_type_OTHER.setValueTextColor(Color.WHITE);
                            dataSet_by_type.setValueTextSize(7f);
                            dataSet_by_type_MINOR.setValueTextSize(7f);
                            dataSet_by_type_MEDIUM.setValueTextSize(7f);
                            dataSet_by_type_MAJOR.setValueTextSize(7f);
                            dataSet_by_type_OTHER.setValueTextSize(7f);

                            data_type.setBarWidth(.5f);

                            data_type.setValueFormatter(new ValueFormatter() {
                                @Override
                                public String getBarLabel(BarEntry barEntry) {
                                    int barEntryY = (int) barEntry.getY();

                                    return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                                }
                            });

                        Legend l_type_MAJOR = barchart_type.getLegend();
                        l_type_MAJOR.setCustom(legends_type_MAJOR);
                        l_type_MAJOR.setWordWrapEnabled(true);
                        l_type_MAJOR.setDrawInside(true);
                        data_type_MAJOR.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();
                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });
                        data_type_MAJOR.setBarWidth(.5f);

                        Legend l_type_OTHER = barchart_type.getLegend();
                        l_type_OTHER.setCustom(legends_type_OTHER);
                        l_type_OTHER.setWordWrapEnabled(true);
                        l_type_OTHER.setDrawInside(true);
                        data_type_OTHER.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();
                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });
                        data_type_OTHER.setBarWidth(.5f);

                        Legend l_type_MINOR = barchart_type.getLegend();
                        l_type_MINOR.setCustom(legends_type_MINOR);
                        l_type_MINOR.setWordWrapEnabled(true);
                        l_type_MINOR.setDrawInside(true);
                        data_type_MINOR.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();

                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });

                        Legend l_type_MEDIUM = barchart_type.getLegend();
                        l_type_MEDIUM.setCustom(legends_type_MEDIUM);
                        l_type_MEDIUM.setWordWrapEnabled(true);
                        l_type_MEDIUM.setDrawInside(true);
                        data_type_MEDIUM.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();

                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });

                            barchart_type.setRenderer(new MyRenderer(barchart_type, barchart_type.getAnimator(), barchart_type.getViewPortHandler()));

                            Legend l_type = barchart_type.getLegend();
                            l_type.setCustom(legends_type);
                            l_type.setWordWrapEnabled(true);
                            l_type.setDrawInside(true);
                            piechart_defects.setData(data_defect);
                            piechart_defects.invalidate();
                            piechart_source.setData(data_source);
                            piechart_source.invalidate();

                            barchart_type.getAxisLeft().setEnabled(false);
                            barchart_type.setScaleEnabled(false);
                            barchart_type.getAxisRight().setEnabled(false);
                            barchart_type.getAxisRight().setDrawGridLines(false);
                            barchart_type.getXAxis().setDrawLabels(false);
                            barchart_type.getXAxis().setDrawGridLines(false);
                            barchart_type.getDescription().setEnabled(false);
                            barchart_type.getLegend().setEnabled(false);
                            barchart_type.setBorderColor(Color.BLACK);
                            barchart_type.setDrawBorders(false);

                            barchart_type.setData(data_type);
                            barchart_type.setMinimumHeight(arr_by_type.size()*250);
                            barchart_type.invalidate();
                            Log.e("INFO BAR", data_type.toString());

                        piechart_defects.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
                            @Override
                            public void onValueSelected(Entry e, Highlight h) {
                                String value = String.valueOf((int)h.getY());
                                String toShow = "";
                                if(h.getX() == 0){
                                    toShow = " MAJOR \n" + value;
                                    chartSelectedDefect = "MAJOR";
                                    barchart_type.setData(data_type_MAJOR);
                                }else if(h.getX() == 1){
                                    toShow = " MEDIUM \n" + value;
                                    chartSelectedDefect = "MEDIUM";
                                    barchart_type.setData(data_type_MEDIUM);
                                    barchart_type.invalidate();
                                }else if(h.getX() == 2){
                                    toShow = " MINOR \n" + value ;
                                    chartSelectedDefect = "MINOR";
                                    barchart_type.setData(data_type_MINOR);
                                }else if(h.getX() == 3){
                                    toShow = " OTHER \n" + value;
                                    chartSelectedDefect = "OTHER";
                                    barchart_type.setData(data_type_OTHER);
```

How it appears when I show all:

Body:
I don't know if I'm using the correct way of filtering a barchart, or even if my code is properly written.

But I have  problem, when I open my dashboard, I have 3 charts, one of the piecharts can filter the barchart, and depending on which was selected, the barchart only shows the piechart selected, otherwise shows all.

My problem is when I filter those, I'm getting the correct filter, but I can't get the labels to appear, they just appear when I got only one, for example if I have 1Yellow, 15 Reds, its only a bar to show, but it only shows the label for the yellow one, but if yellow2 and 15 reds, it doesn't show any of them.

It should be a easy fix, I just can't see where is the error.

ArrayList<Integer> colors_to_add_type = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_MINOR = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_MEDIUM = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_MAJOR = new ArrayList<>();
                            ArrayList<Integer> colors_to_add_type_OTHER = new ArrayList<>();
                            Iterator<String> defects_colors_keys;
                            defects_colors_keys = colors_type.keys();
                            while (defects_colors_keys.hasNext()){
                                String key = defects_colors_keys.next();
                                Log.e("COLOR_KEY", "onResponse: " + key );
                                int to_add = Color.parseColor(colors_type.getString(key));
                                int to_add_MINOR = Color.parseColor("#00FF00");
                                int to_add_MEDIUM = Color.parseColor("#FFFF00");
                                int to_add_MAJOR = Color.parseColor("#FF0000");
                                int to_add_OTHER = Color.parseColor("#800080");
                                Log.e("COLOR_NAME", "onResponse: " + colors_type.getString(key));
                                colors_to_add_type.add(to_add);
                                colors_to_add_type_MAJOR.add(to_add_MAJOR);
                                colors_to_add_type_MEDIUM.add(to_add_MEDIUM);
                                colors_to_add_type_MINOR.add(to_add_MINOR);
                                colors_to_add_type_OTHER.add(to_add_OTHER);
                            }
                            List<LegendEntry> legends_type = new ArrayList<>();
                            List<LegendEntry> legends_type_MINOR = new ArrayList<>();
                            List<LegendEntry> legends_type_MEDIUM = new ArrayList<>();
                            List<LegendEntry> legends_type_MAJOR = new ArrayList<>();
                            List<LegendEntry> legends_type_OTHER = new ArrayList<>();
                                type_of_defects = by_type.keys();
                                int c = 0;
                                if(!map_defects_by_type_count.isEmpty()){
                                    map_defects_by_type_count.clear();
                                }
                                Log.e("DEFECTS", defects_list.toString());
                                Log.e("DEFECTS",String.valueOf(defects_list.size()));
                                while(type_of_defects.hasNext()) {
                                    String key = type_of_defects.next();
                                    Log.e("DEFECTS_type", key.toString());
                                    map_defects_by_type_count.put(key, by_type.getInt(key));
                                    map_get_defect_type.put(c, key);
                                    LegendEntry legendEntry = new LegendEntry();
                                    legendEntry.label = key;
                                    legendEntry.formColor = colors_to_add_type.get(c);
                                    legends_type.add(legendEntry);
                                    arr_by_type.add(new BarEntry((float)c + 1, (int)by_type.getInt(key), (String)key));
                                    c++;
                                    for (int i = 0; i < defects_list.size(); i++){
                                        if (defects_list.get(i).getStringProperty("defect").equals(key)){
                                            if (defects_list.get(i).getStringProperty("criticality").equals("MAJOR")){
                                                arr_by_type_MAJOR.add(new BarEntry((float)c +1, (int)by_type.getInt(key), (String)key));
                                                legends_type_MAJOR.add(legendEntry);
                                                break;
                                            }
                                            if (defects_list.get(i).getStringProperty("criticality").equals("MEDIUM")){
                                                arr_by_type_MEDIUM.add(new BarEntry((float)c +1 , (int)by_type.getInt(key), (String)key));
                                                legends_type_MEDIUM.add(legendEntry);
                                                break;
                                            }
                                            if (defects_list.get(i).getStringProperty("criticality").equals("MINOR")){
                                                arr_by_type_MINOR.add(new BarEntry((float)c +1, (int)by_type.getInt(key), (String)key));
                                                legends_type_MINOR.add(legendEntry);
                                                break;
                                            }
                                            if (defects_list.get(i).getStringProperty("criticality").equals("OTHER")){
                                                arr_by_type_OTHER.add(new BarEntry((float)c +1, (int)by_type.getInt(key), (String)key));
                                                legends_type_OTHER.add(legendEntry);
                                                break;
                                            }
                                        }
                                    }
                                }
                                TOTAL_DEFECTS = TOTAL_BY_CRIT;
                            if(TOTAL_BY_CRIT != 0){
                                if(MAJOR != 0){
                                    major_percent =  (float) MAJOR / TOTAL_BY_CRIT;
                                }
                                if(MEDIUM != 0){
                                    medium_percent =  (float) MEDIUM / TOTAL_BY_CRIT;
                                }
                                if(MINOR != 0){
                                    minor_percent = (float) MINOR / TOTAL_BY_CRIT;
                                }
                                if(OTHER != 0){
                                    other_percent = (float) OTHER / TOTAL_BY_CRIT;
                                }
                            }

                            TOTAL_SOURCE = TOTAL_H_M;
                            if(TOTAL_H_M != 0){
                                if(HUMAN != 0){
                                    human_percent = (float) HUMAN / TOTAL_H_M;
                                }
                                if(MACHINE != 0){
                                    machine_percent = (float) MACHINE / TOTAL_H_M;
                                }
                            }
                            arr_by_defect.add(new PieEntry(MAJOR, "MAJOR"));
                            arr_by_defect.add(new PieEntry(MEDIUM, "MEDIUM"));
                            arr_by_defect.add(new PieEntry(MINOR, "MINOR"));
                            arr_by_defect.add(new PieEntry(OTHER, "OTHER"));
                            arr_by_source.add(new PieEntry(HUMAN, "HUMAN"));
                            arr_by_source.add(new PieEntry(MACHINE, "MACHINE"));
                            dataSet_by_defect = new PieDataSet(arr_by_defect, "");
                            dataSet_by_source = new PieDataSet(arr_by_source, "");
                            dataSet_by_type = new BarDataSet(arr_by_type, "");
                            dataSet_by_type_MAJOR = new BarDataSet(arr_by_type_MAJOR, "");
                            dataSet_by_type_MEDIUM = new BarDataSet(arr_by_type_MEDIUM, "");
                            dataSet_by_type_MINOR = new BarDataSet(arr_by_type_MINOR, "");
                            dataSet_by_type_OTHER = new BarDataSet(arr_by_type_OTHER, "");
                            //GET THE COLORS
                            String colorMajor = colors.getString("MAJOR");
                            String colorMedium = colors.getString("MEDIUM");
                            String colorMinor = colors.getString("MINOR");
                            String colorOther = colors.getString("OTHER");
                            String colorHuman = human_machine_colors.getString("human");
                            String colorMachine = human_machine_colors.getString("machine");
                            final int[] sliceColors = {Color.parseColor(colorMajor), Color.parseColor(colorMedium), Color.parseColor(colorMinor), Color.parseColor(colorOther)};
                            ArrayList<Integer> colorsSet = new ArrayList<>();
                            for (int color : sliceColors){
                                colorsSet.add(color);
                            }
                            Log.e("COLORS_TO ADD", "MAJOR" + colorMajor);
                            Log.e("COLORS_TO ADD", "MEDIUM" + colorMedium);
                            Log.e("COLORS_TO ADD", "MINOR" + colorMinor);
                            Log.e("COLORS_TO ADD", "OTHER" + colorOther);
                            dataSet_by_defect.setColors(colorsSet);
                            final int[] sliceColors_hm = {Color.parseColor(colorHuman), Color.parseColor(colorMachine)};
                            ArrayList<Integer> colorsSet_hm = new ArrayList<>();
                            for (int color : sliceColors_hm){
                                colorsSet_hm.add(color);
                            }
                            dataSet_by_source.setColors(colorsSet_hm);
                            dataSet_by_type.setColors(colors_to_add_type);
                            dataSet_by_type_MINOR.setColors(colors_to_add_type_MINOR);
                            dataSet_by_type_MEDIUM.setColors(colors_to_add_type_MEDIUM);
                            dataSet_by_type_MAJOR.setColors(colors_to_add_type_MAJOR);
                            dataSet_by_type_OTHER.setColors(colors_to_add_type_OTHER);
                            dataSet_by_type.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_MINOR.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_MEDIUM.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_MAJOR.setAxisDependency(YAxis.AxisDependency.RIGHT);
                            dataSet_by_type_OTHER.setAxisDependency(YAxis.AxisDependency.RIGHT);

                            final PieData data_defect = new PieData(dataSet_by_defect);
                            final PieData data_source = new PieData(dataSet_by_source);
                            final BarData data_type = new BarData(dataSet_by_type);
                            final BarData data_type_MINOR = new BarData(dataSet_by_type_MINOR);
                            final BarData data_type_MEDIUM = new BarData(dataSet_by_type_MEDIUM);
                            final BarData data_type_MAJOR = new BarData(dataSet_by_type_MAJOR);
                            final BarData data_type_OTHER = new BarData(dataSet_by_type_OTHER);
                            data_type.setDrawValues(true);
                            data_type_MAJOR.setDrawValues(true);
                            data_type_MEDIUM.setDrawValues(true);
                            data_type_MINOR.setDrawValues(true);
                            data_type_OTHER.setDrawValues(true);

                            data_defect.setDrawValues(false);
                            data_source.setDrawValues(false);
                            //data_type.setBarWidth(.75f);
                            piechart_defects.setDrawHoleEnabled(true);
                            piechart_defects.setHoleColor(Color.TRANSPARENT);
                            piechart_defects.setDrawEntryLabels(false);
                            piechart_defects.setDrawMarkers(false);
                            piechart_defects.setCenterText(String.valueOf(TOTAL_DEFECTS) + " TOTAL");
                            piechart_defects.setCenterTextSize(10);
                            piechart_defects.getDescription().setEnabled(false);
                            Legend l_defect = piechart_defects.getLegend();
                            l_defect.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
                            l_defect.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
                            l_defect.setOrientation(Legend.LegendOrientation.VERTICAL);
                            l_defect.setDrawInside(false);
                            l_defect.setEnabled(true);
                            l_defect.setFormSize(4f);
                            l_defect.setTextColor(Color.WHITE);
                            l_defect.setTextSize(.5f);
                            piechart_source.setDrawHoleEnabled(true);
                            piechart_source.setDrawEntryLabels(false);
                            piechart_source.setHoleColor(Color.TRANSPARENT);
                            piechart_source.setDrawMarkers(false);
                            piechart_source.setCenterText(String.valueOf(TOTAL_SOURCE) + " TOTAL");
                            piechart_source.setCenterTextSize(10);
                            piechart_source.getDescription().setEnabled(false);
                            piechart_source.setTransparentCircleRadius(10f);
                            Legend l_source = piechart_source.getLegend();
                            l_source.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
                            l_source.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
                            l_source.setOrientation(Legend.LegendOrientation.VERTICAL);
                            l_source.setDrawInside(false);
                            l_source.setEnabled(true);
                            l_source.setFormSize(4f);
                            l_source.setTextColor(Color.WHITE);
                            l_source.setTextSize(.5f);
                            dataSet_by_type.setValueTextColor(Color.WHITE);
                            dataSet_by_type_MAJOR.setValueTextColor(Color.WHITE);
                            dataSet_by_type_MEDIUM.setValueTextColor(Color.WHITE);
                            dataSet_by_type_MINOR.setValueTextColor(Color.WHITE);
                            dataSet_by_type_OTHER.setValueTextColor(Color.WHITE);
                            dataSet_by_type.setValueTextSize(7f);
                            dataSet_by_type_MINOR.setValueTextSize(7f);
                            dataSet_by_type_MEDIUM.setValueTextSize(7f);
                            dataSet_by_type_MAJOR.setValueTextSize(7f);
                            dataSet_by_type_OTHER.setValueTextSize(7f);

                            data_type.setBarWidth(.5f);

                            data_type.setValueFormatter(new ValueFormatter() {
                                @Override
                                public String getBarLabel(BarEntry barEntry) {
                                    int barEntryY = (int) barEntry.getY();

                                    return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                                }
                            });

                        Legend l_type_MAJOR = barchart_type.getLegend();
                        l_type_MAJOR.setCustom(legends_type_MAJOR);
                        l_type_MAJOR.setWordWrapEnabled(true);
                        l_type_MAJOR.setDrawInside(true);
                        data_type_MAJOR.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();
                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });
                        data_type_MAJOR.setBarWidth(.5f);

                        Legend l_type_OTHER = barchart_type.getLegend();
                        l_type_OTHER.setCustom(legends_type_OTHER);
                        l_type_OTHER.setWordWrapEnabled(true);
                        l_type_OTHER.setDrawInside(true);
                        data_type_OTHER.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();
                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });
                        data_type_OTHER.setBarWidth(.5f);

                        Legend l_type_MINOR = barchart_type.getLegend();
                        l_type_MINOR.setCustom(legends_type_MINOR);
                        l_type_MINOR.setWordWrapEnabled(true);
                        l_type_MINOR.setDrawInside(true);
                        data_type_MINOR.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();

                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });

                        Legend l_type_MEDIUM = barchart_type.getLegend();
                        l_type_MEDIUM.setCustom(legends_type_MEDIUM);
                        l_type_MEDIUM.setWordWrapEnabled(true);
                        l_type_MEDIUM.setDrawInside(true);
                        data_type_MEDIUM.setValueFormatter(new ValueFormatter() {
                            @Override
                            public String getBarLabel(BarEntry barEntry) {
                                int barEntryY = (int) barEntry.getY();

                                return (String)barEntry.getData() + "  " + "(" + String.valueOf(barEntryY) + ")";
                            }
                        });

                            barchart_type.setRenderer(new MyRenderer(barchart_type, barchart_type.getAnimator(), barchart_type.getViewPortHandler()));

                            Legend l_type = barchart_type.getLegend();
                            l_type.setCustom(legends_type);
                            l_type.setWordWrapEnabled(true);
                            l_type.setDrawInside(true);
                            piechart_defects.setData(data_defect);
                            piechart_defects.invalidate();
                            piechart_source.setData(data_source);
                            piechart_source.invalidate();

                            barchart_type.getAxisLeft().setEnabled(false);
                            barchart_type.setScaleEnabled(false);
                            barchart_type.getAxisRight().setEnabled(false);
                            barchart_type.getAxisRight().setDrawGridLines(false);
                            barchart_type.getXAxis().setDrawLabels(false);
                            barchart_type.getXAxis().setDrawGridLines(false);
                            barchart_type.getDescription().setEnabled(false);
                            barchart_type.getLegend().setEnabled(false);
                            barchart_type.setBorderColor(Color.BLACK);
                            barchart_type.setDrawBorders(false);

                            barchart_type.setData(data_type);
                            barchart_type.setMinimumHeight(arr_by_type.size()*250);
                            barchart_type.invalidate();
                            Log.e("INFO BAR", data_type.toString());

                        piechart_defects.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
                            @Override
                            public void onValueSelected(Entry e, Highlight h) {
                                String value = String.valueOf((int)h.getY());
                                String toShow = "";
                                if(h.getX() == 0){
                                    toShow = " MAJOR \n" + value;
                                    chartSelectedDefect = "MAJOR";
                                    barchart_type.setData(data_type_MAJOR);
                                }else if(h.getX() == 1){
                                    toShow = " MEDIUM \n" + value;
                                    chartSelectedDefect = "MEDIUM";
                                    barchart_type.setData(data_type_MEDIUM);
                                    barchart_type.invalidate();
                                }else if(h.getX() == 2){
                                    toShow = " MINOR \n" + value ;
                                    chartSelectedDefect = "MINOR";
                                    barchart_type.setData(data_type_MINOR);
                                }else if(h.getX() == 3){
                                    toShow = " OTHER \n" + value;
                                    chartSelectedDefect = "OTHER";
                                    barchart_type.setData(data_type_OTHER);

How it appears when I show all:


问:
Using multiple unnamed arguments (... ellipses) in custom function
I am new to writing custom functions in R.

I have a dataset that has the same graph format applied to it multiple times. So instead of copying and pasting the code, and modifying for each dataset, I want to create a function.

I have multiple layers in a ggplot graph. I want to be able to use the ... argument for most of the layers. For example, if I put the ... as size = 10, it makes the line thicker, and the jitter points larger. What if I only want size = 10 to apply to stat_summary, and not geom_jitter etc.?

Using the iris dataset this is what I have tried so far:

```<code>jitter_graph_mm1 <- function(data, x, y, xlab = NULL, ylab = NULL, ...) {
  ggplot(data, aes({{x}}, {{y}})) +
    stat_summary(fun = median, show.legend = FALSE, geom="crossbar", ...) +
    geom_jitter(show.legend = FALSE, width = 0.25, ...) +
    labs(x=xlab, y=ylab)
}

jitter_graph_mm1(data=iris, x=Species, y=Sepal.Width, ylab = "hi", size = 10)
</code>```

Body:
I am new to writing custom functions in R.

I have a dataset that has the same graph format applied to it multiple times. So instead of copying and pasting the code, and modifying for each dataset, I want to create a function.

I have multiple layers in a ggplot graph. I want to be able to use the ... argument for most of the layers. For example, if I put the ... as size = 10, it makes the line thicker, and the jitter points larger. What if I only want size = 10 to apply to stat_summary, and not geom_jitter etc.?

Using the iris dataset this is what I have tried so far:

jitter_graph_mm1 <- function(data, x, y, xlab = NULL, ylab = NULL, ...) {
  ggplot(data, aes({{x}}, {{y}})) +
    stat_summary(fun = median, show.legend = FALSE, geom="crossbar", ...) +
    geom_jitter(show.legend = FALSE, width = 0.25, ...) +
    labs(x=xlab, y=ylab)
}

jitter_graph_mm1(data=iris, x=Species, y=Sepal.Width, ylab = "hi", size = 10)


问:
SPFx web part with TinyMCE self-hosted does not render in packaged solution
I have an SPFx web part which contains TinyMCE self-hosted component. The webpart's editor component in RichEditor.tsx file returns  node with 'tinymceScriptSrc' property. The tinymceScriptSrc has value to tinymce.min.js file.

This works as expected while executing in workbench but does not turn up in packaged solution.

Executed gulp serve command and the webpart shows TinyMCE component in workbench.aspx. However, it does not appear in a webpart from packaged solution.


问:
How to generate migrations with typeorm in nestjs
Always occur problem "No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command"

package.json script:

```<code>  "typeorm": "typeorm-ts-node-commonjs",
  "migration:generate": "yarn build &&  yarn typeorm migration:generate -d typeorm.config.ts -o ./dist/database/migrations/auto"
</code>```

typeorm.config.ts:

```<code>dotenv.config();
const isDev = process.env.NODE_ENV === 'development';
export const dbConnection: DataSourceOptions = {
  type: 'postgres',
  host: process.env.DB_HOST,
  port: Number(process.env.DB_PORT),
  username: process.env.DB_USERNAME,
  password: String(process.env.DB_PASSWORD),
  database: process.env.DB_NAME,
  logging: true,
  entities: ['./dist/src/entities/*.entity.js'],
  migrations: ['./dist/src/migrations/*.js'],
  synchronize: isDev,
  migrationsRun: true,
};

const AppDataSource = new DataSource(dbConnection);
</code>```

src path

dist path

I need generate correctly migrations with sql commands in dist directories

Body:
Always occur problem "No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command"

package.json script:

  "typeorm": "typeorm-ts-node-commonjs",
  "migration:generate": "yarn build &&  yarn typeorm migration:generate -d typeorm.config.ts -o ./dist/database/migrations/auto"

typeorm.config.ts:

dotenv.config();
const isDev = process.env.NODE_ENV === 'development';
export const dbConnection: DataSourceOptions = {
  type: 'postgres',
  host: process.env.DB_HOST,
  port: Number(process.env.DB_PORT),
  username: process.env.DB_USERNAME,
  password: String(process.env.DB_PASSWORD),
  database: process.env.DB_NAME,
  logging: true,
  entities: ['./dist/src/entities/*.entity.js'],
  migrations: ['./dist/src/migrations/*.js'],
  synchronize: isDev,
  migrationsRun: true,
};

const AppDataSource = new DataSource(dbConnection);

src path

dist path

I need generate correctly migrations with sql commands in dist directories


问:
Secured Asp.net Core2.2 WebAPI with Azure AD Authentication is not working on IIS but working fine on IIS Express using Visual Studio
I created web API using .NET Core 2.2 and authenticate with Azure AD using username and password with:

```<code>await app.AcquireTokenByUsernamePassword(scopes, userName, Password).ExecuteAsync();
</code>```

Using Visual Studio web API authentication code is working fine But When the same API is deployed on IIS we get the below exception for:

```<code>await app.AcquireTokenByUsernamePassword(scopes, userName, Password).ExecuteAsync();
</code>```

authentication method.

InnerException:

The operation was canceled.

```<code>Stack Exception: at System.Net.Http.HttpClient.HandleFinishSendAsyncError(Exception e, CancellationTokenSource cts)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.Identity.Client.Http.HttpManager.ExecuteAsync(Uri endpoint, IDictionary`2 headers, HttpContent body, HttpMethod method, ILoggerAdapter logger, CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Http.HttpManager.ExecuteWithRetryAsync(Uri endpoint, IDictionary`2 headers, HttpContent body, HttpMethod method, ILoggerAdapter logger, Boolean doNotThrow, Boolean retry, CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Http.HttpManager.SendGetAsync(Uri endpoint, IDictionary`2 headers, ILoggerAdapter logger, Boolean retry, CancellationToken cancellationToken)
   at Microsoft.Identity.Client.OAuth2.OAuth2Client.ExecuteRequestAsync[T](Uri endPoint, HttpMethod method, RequestContext requestContext, Boolean expectErrorsOn200OK, Boolean addCommonHeaders, Func`2 onBeforePostRequestData)
   at Microsoft.Identity.Client.OAuth2.OAuth2Client.DiscoverAadInstanceAsync(Uri endPoint, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.SendInstanceDiscoveryRequestAsync(Uri authority, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.FetchAllDiscoveryMetadataAsync(Uri authority, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.GetMetadataAsync(Uri authority, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.FetchNetworkMetadataOrFallbackAsync(RequestContext requestContext, Uri authorityUri)
   at Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.GetMetadataEntryAsync(AuthorityInfo authorityInfo, RequestContext requestContext, Boolean forceValidation)
   at Microsoft.Identity.Client.Instance.AuthorityManager.RunInstanceDiscoveryAndValidationAsync()
   at Microsoft.Identity.Client.Internal.Requests.UsernamePasswordRequest.ExecuteAsync(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenByUsernamePasswordParameters usernamePasswordParameters, CancellationToken cancellationToken)
</code>```

Authrntication Code:

```<code>string clientId = "XXXXXXXXXXXXX";
string tenanat = "XXXXXXXXXXXXXXXXXXXX";
string authority = "https://login.microsoftonline.com/" + tenanat;
string[] scopes = new string[] { "user.read" };
IPublicClientApplication app;
app = PublicClientApplicationBuilder.Create(clientId)
    .WithAuthority(authority)
    .Build();
var securePassword = new SecureString();
foreach (char c in Password.ToCharArray())
    securePassword.AppendChar(c);

var result = await app.AcquireTokenByUsernamePassword(scopes, userName, Password)ExecuteAsync();
return result.IdToken;
</code>```
```<code>string clientId = "XXXXXXXXXXXXX";
string tenanat = "XXXXXXXXXXXXXXXXXXXX";

string authority = "https://login.microsoftonline.com/" + tenanat;
string[] scopes = new string[] { "user.read" };

IPublicClientApplication app;
app = PublicClientApplicationBuilder.Create(clientId)
    .WithAuthority(authority)
    .Build();
var securePassword = new SecureString();
foreach (char c in Password.ToCharArray())
    securePassword.AppendChar(c);

var result = await app.AcquireTokenByUsernamePassword(scopes, userName, Password).ExecuteAsync();
return result.IdToken;
</code>```

Body:
I created web API using .NET Core 2.2 and authenticate with Azure AD using username and password with:

await app.AcquireTokenByUsernamePassword(scopes, userName, Password).ExecuteAsync();

Using Visual Studio web API authentication code is working fine But When the same API is deployed on IIS we get the below exception for:

await app.AcquireTokenByUsernamePassword(scopes, userName, Password).ExecuteAsync();

authentication method.

InnerException:

The operation was canceled.

Stack Exception: at System.Net.Http.HttpClient.HandleFinishSendAsyncError(Exception e, CancellationTokenSource cts)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.Identity.Client.Http.HttpManager.ExecuteAsync(Uri endpoint, IDictionary`2 headers, HttpContent body, HttpMethod method, ILoggerAdapter logger, CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Http.HttpManager.ExecuteWithRetryAsync(Uri endpoint, IDictionary`2 headers, HttpContent body, HttpMethod method, ILoggerAdapter logger, Boolean doNotThrow, Boolean retry, CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Http.HttpManager.SendGetAsync(Uri endpoint, IDictionary`2 headers, ILoggerAdapter logger, Boolean retry, CancellationToken cancellationToken)
   at Microsoft.Identity.Client.OAuth2.OAuth2Client.ExecuteRequestAsync[T](Uri endPoint, HttpMethod method, RequestContext requestContext, Boolean expectErrorsOn200OK, Boolean addCommonHeaders, Func`2 onBeforePostRequestData)
   at Microsoft.Identity.Client.OAuth2.OAuth2Client.DiscoverAadInstanceAsync(Uri endPoint, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.SendInstanceDiscoveryRequestAsync(Uri authority, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.FetchAllDiscoveryMetadataAsync(Uri authority, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.NetworkMetadataProvider.GetMetadataAsync(Uri authority, RequestContext requestContext)
   at Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.FetchNetworkMetadataOrFallbackAsync(RequestContext requestContext, Uri authorityUri)
   at Microsoft.Identity.Client.Instance.Discovery.InstanceDiscoveryManager.GetMetadataEntryAsync(AuthorityInfo authorityInfo, RequestContext requestContext, Boolean forceValidation)
   at Microsoft.Identity.Client.Instance.AuthorityManager.RunInstanceDiscoveryAndValidationAsync()
   at Microsoft.Identity.Client.Internal.Requests.UsernamePasswordRequest.ExecuteAsync(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
   at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenByUsernamePasswordParameters usernamePasswordParameters, CancellationToken cancellationToken)

Authrntication Code:

string clientId = "XXXXXXXXXXXXX";
string tenanat = "XXXXXXXXXXXXXXXXXXXX";
string authority = "https://login.microsoftonline.com/" + tenanat;
string[] scopes = new string[] { "user.read" };
IPublicClientApplication app;
app = PublicClientApplicationBuilder.Create(clientId)
    .WithAuthority(authority)
    .Build();
var securePassword = new SecureString();
foreach (char c in Password.ToCharArray())
    securePassword.AppendChar(c);

var result = await app.AcquireTokenByUsernamePassword(scopes, userName, Password)ExecuteAsync();
return result.IdToken;

string clientId = "XXXXXXXXXXXXX";
string tenanat = "XXXXXXXXXXXXXXXXXXXX";

string authority = "https://login.microsoftonline.com/" + tenanat;
string[] scopes = new string[] { "user.read" };

IPublicClientApplication app;
app = PublicClientApplicationBuilder.Create(clientId)
    .WithAuthority(authority)
    .Build();
var securePassword = new SecureString();
foreach (char c in Password.ToCharArray())
    securePassword.AppendChar(c);

var result = await app.AcquireTokenByUsernamePassword(scopes, userName, Password).ExecuteAsync();
return result.IdToken;


问:
Null detection with Linq in Visual Studio 2022
I write the following code in VS2022:

```<code>var approvalResultHistory = cardData.CardData.SignTicketApproval
                .OrderBy(x => x.CreateTime)
                .Select(x => x.Result)
                .Where(result => result != null)
                .Select(result => new ApprovalResultHistory
                {
                    ApproverName = _wackerUserService.GetUserProfileByEmail(result.ApproverEmail).DisplayName,
                    Outcome = result.Outcome,
                    Comment = result.Comment,
                    CreateTime = result.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
});
</code>```

However, VS told me the "result" in the last Select maybe Null and give me a warning. I think I have already excluded all null values in Where. Do I miss something? or is VS making a false warning?

Thank you.

Body:
I write the following code in VS2022:

var approvalResultHistory = cardData.CardData.SignTicketApproval
                .OrderBy(x => x.CreateTime)
                .Select(x => x.Result)
                .Where(result => result != null)
                .Select(result => new ApprovalResultHistory
                {
                    ApproverName = _wackerUserService.GetUserProfileByEmail(result.ApproverEmail).DisplayName,
                    Outcome = result.Outcome,
                    Comment = result.Comment,
                    CreateTime = result.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")
});

However, VS told me the "result" in the last Select maybe Null and give me a warning. I think I have already excluded all null values in Where. Do I miss something? or is VS making a false warning?

Thank you.


问:
How to properly type assigned properties to a class in a forEach method?
Suppose the following code:

```<code>type TDone =  (res: string) => void;
type TFail =  (res: string) => void;

class Effect {
  _done?: TDone;
  _fail?: TFail;

  constructor({ done: _done, fail: _fail }: { done?: TDone, fail?: TFail }) {
    this._done = _done;
    this._fail = _fail;
  }

  done() {
    return this._done?.('ok!')
  }

  fail() {
    return this._fail?.('fail!')
  }
}

const createEffect = (watchers : { done?: TDone, fail?: TFail }) => {
  const effect = new Effect({});

  Object.keys(watchers).forEach((watcher) => {
    effect[watcher] = watchers[watcher];
  })

  return effect;
}

const effect = createEffect({ done: () => console.log('done!') });

effect.fail();
</code>```

This throws an error here:

```<code>Object.keys(watchers).forEach((watcher) => {
  effect[watcher] = watchers[watcher];
  ^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^
})
</code>```

How can I properly type this? I've tried different combinations of keyof typeof but to no avail.

Typescript playground

Body:
Suppose the following code:

type TDone =  (res: string) => void;
type TFail =  (res: string) => void;

class Effect {
  _done?: TDone;
  _fail?: TFail;

  constructor({ done: _done, fail: _fail }: { done?: TDone, fail?: TFail }) {
    this._done = _done;
    this._fail = _fail;
  }

  done() {
    return this._done?.('ok!')
  }

  fail() {
    return this._fail?.('fail!')
  }
}

const createEffect = (watchers : { done?: TDone, fail?: TFail }) => {
  const effect = new Effect({});

  Object.keys(watchers).forEach((watcher) => {
    effect[watcher] = watchers[watcher];
  })

  return effect;
}

const effect = createEffect({ done: () => console.log('done!') });

effect.fail();

This throws an error here:

Object.keys(watchers).forEach((watcher) => {
  effect[watcher] = watchers[watcher];
  ^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^
})

How can I properly type this? I've tried different combinations of keyof typeof but to no avail.

<a href="https://www.typescriptlang.org/play?#code/C4TwDgpgBAKgIgewHbQLxSgCgE4QM4BcUew2AlkgOYCUUqAfFAG4JkAmA3AFCiSwBiAQzIAbOhhz4iJclVoNmrTly4BjEYLx4oAUQBmeiKuBQA3lwwB9NsggB+IvFvcre4SIcD33C1FXIZAFdjBGxMUygbFCJrWwAaKDdRGKSxAF8iCKj7R0QUBNTPGCFRKDTacwwMYAALMjwAOliUcWaIFyra+qbU1tSOtJUMbMwK3wxcYEDsJCguxra7BswAcgQAawBCFepfQd9U0bNxqEnp2fme9yXV1O3djEH9-yQSP1xBYAh9Q2NxTAA7p9VDUINhtJlIrYinkIAVro4Sul5IxKn4AiYIAYjCZ0CgAbpscZwuUfBgAPIAIwAVjiGusICA8IDgaDwdQGnpQjpBCDMCzgCCwSjjlUoFjfsAANpAwVsgC64llQvBMtZYPlA12vjOM3FROA3GeGP1kvEqg+Xx+OPCUOiWBFLzwCBEEAaIgQlFW2XuZWoPgldMO-qAA" rel="nofollow noreferrer">Typescript playground


问:
Finding API and accessing it on this particular site
I am trying to identify whether this site "wkotool.nl" has an API.
I want to use this API to write a little script that can access the data for a specific location.
The site for example shows locations of groundwater wells and normally I would go to the site enter a specific location and click all points within a specific radius. From there I always need to type over the coordinates, names etc. This is very time consuming and I was wondering if somebody could show me how to access this specific API and retrieve data from it.

Thank you!


问:
Eclipse IDE add new LaunchGroup mode as a developer
Am trying to add new launch mode here:

For example I want new mode called "Load".
I found this extention point: org.eclipse.debug.ui.launchGroups, which eventually define the launchGroup interface.
I have 2 question:

I found this on internet:

<extension point="org.eclipse.debug.ui.launchGroups">
    <launchGroup
        id="com.example.ExampleLaunchGroupId"
        mode="run"
        label="Run"
        image="icons\run.png"
        bannerImage="icons\runBanner.png">
    </launchGroup>
</extension>
```
<p>"In the above example, the launch group will consist of all launch configurations with no category that support run mode. "
why this will make run mode will disappear?</p>
<ol start="2">
<li>I added this to my code</li>
</ol>
<pre class="lang-xml prettyprint-override"><code><extension point="org.eclipse.debug.ui.launchGroups">
    <launchGroup
        bannerImage="icons/ex.png"
        id="com.ExampleLaunchGroupId"
        image="icons/ex.png"
        label="Load only"
        mode="load">
    </launchGroup>
</extension>
</code>```

in a result the new mode "Load" is added to the "Launch mode" list but the run mode disappeared, why? and how to add the a new mode without delete another one?
thanks

Body:
Am trying to add new launch mode here:

For example I want new mode called "Load".
I found this extention point: org.eclipse.debug.ui.launchGroups, which eventually define the launchGroup interface.
I have 2 question:

I found this on internet:

<extension point="org.eclipse.debug.ui.launchGroups">
    <launchGroup
        id="com.example.ExampleLaunchGroupId"
        mode="run"
        label="Run"
        image="icons\run.png"
        bannerImage="icons\runBanner.png">
    </launchGroup>
</extension>

"In the above example, the launch group will consist of all launch configurations with no category that support run mode. "
why this will make run mode will disappear?

I added this to my code

<extension point="org.eclipse.debug.ui.launchGroups">
    <launchGroup
        bannerImage="icons/ex.png"
        id="com.ExampleLaunchGroupId"
        image="icons/ex.png"
        label="Load only"
        mode="load">
    </launchGroup>
</extension>

in a result the new mode "Load" is added to the "Launch mode" list but the run mode disappeared, why? and how to add the a new mode without delete another one?
thanks


问:
How to change HTML element visibility using JavaScript?
I have searched for a method online on how to change the visibility of my HTML element using JavaScript, but for some reason, all my attempts at making this work have failed, and I can’t recognize why. What’s going wrong here, why is it not working?

<!DOCTYPE html>

  <link rel="stylesheet" type="text/css" href="./style.css" />

<button id="toggle">Hi</button>

```
<pre class="lang-js prettyprint-override"><code>const targetDiv = document.getElementById("block");
const btn = document.getElementById("toggle");

btn.onclick = function() {
  if (targetDiv.style.display !== "none") {
    targetDiv.style.display = "none";
  }
  else {
    targetDiv.style.display = "block";
  }
};
</code>```

#block {
  display: none;
  position: fixed;
  height: 20%;
  width: 50%;
  background-color: #00ff55;
}
```

Body:
I have searched for a method online on how to change the visibility of my HTML element using JavaScript, but for some reason, all my attempts at making this work have failed, and I can’t recognize why. What’s going wrong here, why is it not working?

<!DOCTYPE html>

  <link rel="stylesheet" type="text/css" href="./style.css" />

<button id="toggle">Hi</button>

const targetDiv = document.getElementById("block");
const btn = document.getElementById("toggle");

btn.onclick = function() {
  if (targetDiv.style.display !== "none") {
    targetDiv.style.display = "none";
  }
  else {
    targetDiv.style.display = "block";
  }
};

#block {
  display: none;
  position: fixed;
  height: 20%;
  width: 50%;
  background-color: #00ff55;
}


问:
Error in as.data.frame.default, class coercion 'structure("RasterStack", package = "raster")' in data.frame not possible
`Hello everybody
I get an error when I try to use the predict function. I'm doing a habitat suitability study.
this function requires the model (in this case a glmm) in which I have used trimmed variables, and I want to make the prediction on the same variables but not trimmed.

the varaibles i use in the model are the home range of animals for different climatic o ambient variables, i want predict on a biggest area. all variables are in the same extent, crs and spatial resolution

m
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) \['glmerMod'\] Family: binomial  ( logit ) Formula: as.factor(pres.abs) \~ bio.3.kernel + bio.7.kernel + bio.8.kernel +   bio.9.kernel + bio.13.kernel + bio.15.kernel + prec.7.kernel +   landcover.kernel + slope.k + (1 | id) Data: new AIC       BIC    logLik  deviance  df.resid 21622\.34  21707.70 -10800.17  21600.34     17315 Random effects: Groups Name        Std.Dev. id     (Intercept) 0.1911   Number of obs: 17326, groups:  id, 9 Fixed Effects: (Intercept)      bio.3.kernel      bio.7.kernel      bio.8.kernel      bio.9.kernel     bio.13.kernel   \-0.002928         -0.019971         -0.034466          0.310813         -0.325558         -0.324485   bio.15.kernel     prec.7.kernel  landcover.kernel           slope.k   \-0.671262          0.399149          0.142602          0.429925
names(var2)
`[1] "bio.3.kernel"     "bio.7.kernel"     "bio.8.kernel"     "bio.9.kernel"     "bio.13.kernel"

[6] "bio.15.kernel"    "prec.7.kernel"    "landcover.kernel" "slope.k"

p<- predict(m, var2)

Error in as.data.frame.default(data, optional = TRUE) : class coercion 'structure("RasterBrick", package = "raster")' in data.frame not possible


问:
How to convert JSON and XML request/response mocks to Swagger definitions inside Angular
I'm looking for an angular library that supports converting JSON and XML request/response mocks to Swagger definitions.

Here is an example https://roger13.github.io/SwagDefGen/

Most of what I found generates it to a file but I need it to generate it to code and display inside angular component.