Explore all Keyboard open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Keyboard

Karabiner-Elements

synergy-core

1.14.4.2-snapshot

hotkeys

v3.8.9

sharpkeys

SharpKeys 3.9.4

hotkey

v2.0.0

Popular Libraries in Keyboard

Karabiner-Elements

by pqrs-org doticonc++doticon

star image 14224 doticonUnlicense

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.

mousetrap

by ccampbell doticonjavascriptdoticon

star image 10757 doticonApache-2.0

Simple library for handling keyboard shortcuts in Javascript

synergy-core

by symless doticonc++doticon

star image 8847 doticonGPL-2.0

Open source core of Synergy, the keyboard and mouse sharing tool

hotkeys

by jaywcjlove doticonjavascriptdoticon

star image 5330 doticonMIT

➷ A robust Javascript library for capturing keyboard input. It has no dependencies.

sharpkeys

by randyrants doticoncsharpdoticon

star image 4623 doticonMS-PL

SharpKeys is a utility that manages a Registry key that allows Windows to remap one key to any other key.

Karabiner

by tekezo doticonc++doticon

star image 3824 doticonUnlicense

Karabiner (KeyRemap4MacBook) is a powerful utility for keyboard customization.

tmk_keyboard

by tmk doticoncdoticon

star image 3536 doticon

Keyboard firmwares for Atmel AVR and Cortex-M

qwerty-learner

by Kaiyiwing doticontypescriptdoticon

star image 3020 doticonGPL-3.0

为键盘工作者设计的单词记忆与英语肌肉记忆锻炼软件 / Words learning and English muscle memory training software designed for keyboard workers

hotkey

by github doticonjavascriptdoticon

star image 2618 doticonMIT

Trigger an action on an element with a keyboard shortcut.

Trending New libraries in Keyboard

qwerty-learner

by Kaiyiwing doticontypescriptdoticon

star image 3020 doticonGPL-3.0

为键盘工作者设计的单词记忆与英语肌肉记忆锻炼软件 / Words learning and English muscle memory training software designed for keyboard workers

florisboard

by florisboard doticonkotlindoticon

star image 2610 doticonApache-2.0

An open-source keyboard for Android which respects your privacy. Currently in early-beta.

key-mapper

by sezanzeb doticonpythondoticon

star image 937 doticonGPL-3.0

🎮 An easy to use tool to change the mapping of your input device buttons.

keysim

by crsnbrt doticonjavascriptdoticon

star image 561 doticonMIT

design and test virtual 3d keyboards.

whenipress

by lukeraymonddowning doticonjavascriptdoticon

star image 471 doticonMIT

A tiny, powerful and declarative wrapper around keyboard bindings in JavaScript

python-keyboard

by makerdiary doticonpythondoticon

star image 393 doticonMIT

A hand-wired USB & Bluetooth keyboard powered by Python and more

prk_firmware

by picoruby doticoncdoticon

star image 284 doticonMIT

A keyboard firmware platform in PicoRuby

hotkeys

by ngneat doticontypescriptdoticon

star image 238 doticonMIT

🤖 A declarative library for handling hotkeys in Angular applications

ktrl

by ItayGarin doticonrustdoticon

star image 200 doticonLGPL-3.0

A Supercharged Keyboard Programming Daemon ⌨️

Top Authors in Keyboard

1

simple-keyboard

7 Libraries

star icon171

2

postmarketOS

5 Libraries

star icon112

3

tmk

4 Libraries

star icon3667

4

ibnteo

4 Libraries

star icon67

5

divvun

4 Libraries

star icon28

6

fabi1cazenave

4 Libraries

star icon145

7

AMJKeyboard

3 Libraries

star icon14

8

ErrorErrorError

3 Libraries

star icon19

9

yiancar

3 Libraries

star icon85

10

zsa

3 Libraries

star icon494

1

7 Libraries

star icon171

2

5 Libraries

star icon112

3

4 Libraries

star icon3667

4

4 Libraries

star icon67

5

4 Libraries

star icon28

6

4 Libraries

star icon145

7

3 Libraries

star icon14

8

3 Libraries

star icon19

9

3 Libraries

star icon85

10

3 Libraries

star icon494

Trending Kits in Keyboard

A sprite is an object in a Pygame program that can be moved around on the screen. A sprite typically consists of an image, a rect (position and size) and a list of associated attributes like velocity, acceleration, and behaviour. Sprites can represent characters, projectiles, scenery, or any other game element. 



Moving a sprite in response to keyboard events is a form of game programming where the game responds to user input in key presses. When the user presses a certain key, the game will move the sprite in a predetermined direction. This allows for a more interactive gaming experience by allowing the user to control their character or other objects in the game. 



Pygame is a set of Python modules designed for writing video games. It is open source and free to use, and it provides functionalities such as image handling and sound playback that can be used to create games in Python. Pygame is an easy way to start programming games, and it has been used to create many popular games. 



Here is an example of Moving a sprite in response to keyboard events in PyGame 



Fig1: Preview of the Code



Fig2: Preview of the Output when code is run in IDE.



Fig3: Preview of the Output when left and down keys are pressed respectfully.

Code


In this solution, we will be moving a sprite in response to keyboard events in PyGame.

Instructions


  1. Install Jupyter Notebook on your computer.
  2. Open terminal and install the required libraries with following commands.
  3. Install Pygame - pip install pygame
  4. Copy the snippet using the 'copy' button and paste it into that file.
  5. Run the file using run button.


I hope you found this useful. I have added the link to dependent libraries, version information in the following sections.


I found this code snippet by searching for "Keyboard hold keys to move in PyGame" in kandi. You can try any such use case!

Dependent Libraries

If you do not have Pygame that is required to run this code, you can install it by clicking on the above link and copying the pip Install command from the Pygame page in kandi.


You can search for any dependent library on kandi like Pygame.

Environment Tested


I tested this solution in the following versions. Be mindful of changes when working with other versions.

  1. The solution is created in Python3.9.6
  2. The solution is tested on Pygame 2.3.0 version.


Using this solution, we are able to move a sprite in response to keyboard events in PyGame.



This process also facilities an easy to use, hassle free method to create a hands-on working version of code which would help us to move a sprite in response to keyboard events in PyGame.

Support


  1. For any support on kandi solution kits, please use the chat.
  2. For further learning resources, visit the Open Weaver Community learning page.

Trending Discussions on Keyboard

React Native TextInput closes automatically when opened on android

Apps targeting Android 12 and higher required to specify an explicit value for `android:exported` [Cordova]

PHPickerViewController tapping on Search gets error... "Unable to load photos"

Should I use %$% instead of %>%?

uploaded an APK which has an activity,activity alias,service or broadcast receiver with intentfilter, but without 'android : exported' property set

Vue 3: Module '"../../node_modules/vue/dist/vue"' has no exported member

Paramiko authentication fails with "Agreed upon 'rsa-sha2-512' pubkey algorithm" (and "unsupported public key algorithm: rsa-sha2-512" in sshd log)

Google Keyboard clipboard does not trigger a paste event

Flutter resizeToAvoidBottomInset true not working with Expanded ListView

Getting keyboard navigation to work with MUI Autocomplete and SimpleBar for react

QUESTION

React Native TextInput closes automatically when opened on android

Asked 2022-Apr-05 at 08:36

I switched laptops and cloned the repository of my project, did a quick yarn install and looks like it was a big difference from the one on the main branch but I didn't bother since maybe it's just because of different Node versions.

Now every time I click on one TextInput the keyboard opens and closes immediately only on android. I attached a quick recording here. Tried some solutions and it looks like switching android:windowSoftInputMode from adjustResize to adjustPan in AndroidManifest.xml fixes the problem with the closing but I'm not really happy with the behaviour of the keyboard in the app when it's set to adjustPan. Maybe this issue starting happening a while ago but I just saw it now.

Here is just an input centered inside a simple View. https://gfycat.com/ordinaryquestionabledinosaur

Any suggestions anyone?

ANSWER

Answered 2022-Feb-23 at 16:53

Was facing a similar issue, turned out that the react-native-screens library was causing the problem. Try setting the version to "~3.10.2". Worked out for me.

Source https://stackoverflow.com/questions/71227463

QUESTION

Apps targeting Android 12 and higher required to specify an explicit value for `android:exported` [Cordova]

Asked 2022-Apr-01 at 20:06

When I am running to make the Apk in GitHub I got the error. As I am building the Apk in GitHub. There is no way to define something inside manifest as it is building every time fresh. All I can do is inside the Config.Xml file. After Adding android:exported="false" to it, also getting same error. Both images for this question reference attached here. GitHub Error and Config.Xml. Help will be appreciated.

1<?xml version='1.0' encoding='utf-8'?>
2<widget id="com.likehub.sweetheart" version="1.1.64" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3    <name>sweetheart</name>
4    <description>making love bird together</description>
5    <author email="mynamey9er@gmail.com" href="">likehub</author>
6    <content src="index.html" />
7    <access origin="*" />
8    <allow-intent href="http://*/*" />
9    <allow-intent href="https://*/*" />
10    <allow-intent href="tel:*" />
11    <allow-intent href="sms:*" />
12    <allow-intent href="mailto:*" />
13    <allow-intent href="geo:*" />
14    <preference name="AndroidXEnabled" value="true" />
15    <preference name="WebViewBounce" value="false" />
16    <preference name="UIWebViewBounce" value="false" />
17    <preference name="DisallowOverscroll" value="true" />
18    <preference name="LoadUrlTimeoutValue" value="700000" />
19    <preference name="ScrollEnabled" value="false" />
20    <preference name="SplashMaintainAspectRatio" value="true" />
21    <preference name="FadeSplashScreenDuration" value="1000" />
22    <preference name="FadeSplashScreen" value="true" />
23    <preference name="SplashShowOnlyFirstTime" value="false" />
24    <preference name="SplashScreen" value="screen" />
25    <preference name="SplashScreenDelay" value="5000" />
26    <preference name="AutoHideSplashScreen" value="true" />
27    <preference name="ShowSplashScreen" value="false" />
28    <preference name="ShowSplashScreenSpinner" value="false" />
29    <preference name="android-minSdkVersion" value="22" />
30    <preference name="BackupWebStorage" value="none" />
31    <preference name="Orientation" value="portrait" />
32    <preference name="AndroidPersistentFileLocation" value="Compatibility" />
33    <preference name="GradlePluginKotlinEnabled" value="true" />
34    <preference name="GradlePluginKotlinCodeStyle" value="official" />
35    <preference name="GradlePluginKotlinVersion" value="1.3.50" />
36    <preference name="AndroidLaunchMode" value="singleTask" />
37    <feature name="StatusBar">
38        <param name="ios-package" onload="true" value="CDVStatusBar" />
39    </feature>
40    <platform  name="android">
41        <preference name="android-targetSdkVersion" value="31" />
42        <edit-config  file="app/src/main/AndroidManifest.xml" mode="merge" android:exported="true" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
43            <application android:usesCleartextTraffic="true" />
44            <application android:networkSecurityConfig="@xml/network_security_config" />
45            
46            <intent-filter>
47                <action  android:name="MainActivity" android:exported="false"/>
48                <category android:name="android.intent.category.DEFAULT" />
49            </intent-filter>
50        </edit-config>
51        <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
52        <allow-intent href="market:*" />
53        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
54        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
55        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
56        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
57        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
58        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
59        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
60        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
61        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
62        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
63        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
64        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
65        <splash density="ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
66        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
67        <splash density="mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
68        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
69        <splash density="hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
70        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
71        <splash density="xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
72        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
73        <splash density="xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
74        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
75        <splash density="xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
76        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
77    </platform>
78    <platform name="ios">
79        <allow-intent href="itms:*" />
80        <allow-intent href="itms-apps:*" />
81        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
82        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
83        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
84        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
85        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
86        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
87        <icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
88        <icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
89        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
90        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
91        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
92        <icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
93        <icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
94        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
95        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
96        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
97        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
98        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
99        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
100        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
101        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
102        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
103        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
104        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
105        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
106        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
107        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
108        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
109        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
110        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
111        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
112        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
113        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
114        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
115        <splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
116        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
117        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
118        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
119        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
120        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
121        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
122        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
123        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
124        <splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
125        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
126        <icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
127        <splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
128        <splash height="1242" src="resources/ios/splash/Default-Landscape-2688h~iphone.png" width="2688" />
129        <splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
130        <splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
131    </platform>
132    <plugin name="cordova-plugin-googleplus" spec="^8.4.0">
133        <variable name="WEB_APPLICATION_CLIENT_ID" value="0000000000000-wwwwwwwmkv51oxxxxxxxxxxx.apps.googleusercontent.co" />
134    </plugin>
135    <platform name="android">
136        <preference name="GoogleAndroidClientId" value="888809hhju-i9hd0hc6v51obgdubbgxwbnhiywgdiueh.apps.googleusercontent.com" />
137    </platform>
138    <plugin name="cordova-plugin-whitelist" spec="1.3.5" />
139    <plugin name="cordova-plugin-statusbar" spec="2.4.3" />
140    <plugin name="cordova-plugin-device" spec="2.0.3" />
141    <plugin name="cordova-plugin-splashscreen" spec="6.0.0" />
142    <plugin name="cordova-plugin-ionic-webview" spec="5.0.0" />
143    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.2.0" />
144</widget>

Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

ANSWER

Answered 2021-Nov-18 at 19:22

You can try like this in config.xml under android platform -

1<?xml version='1.0' encoding='utf-8'?>
2<widget id="com.likehub.sweetheart" version="1.1.64" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3    <name>sweetheart</name>
4    <description>making love bird together</description>
5    <author email="mynamey9er@gmail.com" href="">likehub</author>
6    <content src="index.html" />
7    <access origin="*" />
8    <allow-intent href="http://*/*" />
9    <allow-intent href="https://*/*" />
10    <allow-intent href="tel:*" />
11    <allow-intent href="sms:*" />
12    <allow-intent href="mailto:*" />
13    <allow-intent href="geo:*" />
14    <preference name="AndroidXEnabled" value="true" />
15    <preference name="WebViewBounce" value="false" />
16    <preference name="UIWebViewBounce" value="false" />
17    <preference name="DisallowOverscroll" value="true" />
18    <preference name="LoadUrlTimeoutValue" value="700000" />
19    <preference name="ScrollEnabled" value="false" />
20    <preference name="SplashMaintainAspectRatio" value="true" />
21    <preference name="FadeSplashScreenDuration" value="1000" />
22    <preference name="FadeSplashScreen" value="true" />
23    <preference name="SplashShowOnlyFirstTime" value="false" />
24    <preference name="SplashScreen" value="screen" />
25    <preference name="SplashScreenDelay" value="5000" />
26    <preference name="AutoHideSplashScreen" value="true" />
27    <preference name="ShowSplashScreen" value="false" />
28    <preference name="ShowSplashScreenSpinner" value="false" />
29    <preference name="android-minSdkVersion" value="22" />
30    <preference name="BackupWebStorage" value="none" />
31    <preference name="Orientation" value="portrait" />
32    <preference name="AndroidPersistentFileLocation" value="Compatibility" />
33    <preference name="GradlePluginKotlinEnabled" value="true" />
34    <preference name="GradlePluginKotlinCodeStyle" value="official" />
35    <preference name="GradlePluginKotlinVersion" value="1.3.50" />
36    <preference name="AndroidLaunchMode" value="singleTask" />
37    <feature name="StatusBar">
38        <param name="ios-package" onload="true" value="CDVStatusBar" />
39    </feature>
40    <platform  name="android">
41        <preference name="android-targetSdkVersion" value="31" />
42        <edit-config  file="app/src/main/AndroidManifest.xml" mode="merge" android:exported="true" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
43            <application android:usesCleartextTraffic="true" />
44            <application android:networkSecurityConfig="@xml/network_security_config" />
45            
46            <intent-filter>
47                <action  android:name="MainActivity" android:exported="false"/>
48                <category android:name="android.intent.category.DEFAULT" />
49            </intent-filter>
50        </edit-config>
51        <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
52        <allow-intent href="market:*" />
53        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
54        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
55        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
56        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
57        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
58        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
59        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
60        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
61        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
62        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
63        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
64        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
65        <splash density="ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
66        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
67        <splash density="mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
68        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
69        <splash density="hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
70        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
71        <splash density="xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
72        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
73        <splash density="xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
74        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
75        <splash density="xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
76        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
77    </platform>
78    <platform name="ios">
79        <allow-intent href="itms:*" />
80        <allow-intent href="itms-apps:*" />
81        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
82        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
83        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
84        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
85        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
86        <icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
87        <icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
88        <icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
89        <icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
90        <icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
91        <icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
92        <icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
93        <icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
94        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
95        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
96        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
97        <icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
98        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
99        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
100        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
101        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
102        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
103        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
104        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
105        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
106        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
107        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
108        <icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
109        <icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
110        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
111        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
112        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
113        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
114        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
115        <splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
116        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
117        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
118        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
119        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
120        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
121        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
122        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
123        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
124        <splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
125        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
126        <icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
127        <splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
128        <splash height="1242" src="resources/ios/splash/Default-Landscape-2688h~iphone.png" width="2688" />
129        <splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
130        <splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
131    </platform>
132    <plugin name="cordova-plugin-googleplus" spec="^8.4.0">
133        <variable name="WEB_APPLICATION_CLIENT_ID" value="0000000000000-wwwwwwwmkv51oxxxxxxxxxxx.apps.googleusercontent.co" />
134    </plugin>
135    <platform name="android">
136        <preference name="GoogleAndroidClientId" value="888809hhju-i9hd0hc6v51obgdubbgxwbnhiywgdiueh.apps.googleusercontent.com" />
137    </platform>
138    <plugin name="cordova-plugin-whitelist" spec="1.3.5" />
139    <plugin name="cordova-plugin-statusbar" spec="2.4.3" />
140    <plugin name="cordova-plugin-device" spec="2.0.3" />
141    <plugin name="cordova-plugin-splashscreen" spec="6.0.0" />
142    <plugin name="cordova-plugin-ionic-webview" spec="5.0.0" />
143    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.2.0" />
144</widget><edit-config
145  file="app/src/main/AndroidManifest.xml"
146  target="/manifest/application/activity[@android:name='MainActivity']"
147  mode="merge">
148    <activity android:exported="true"/>
149</edit-config>
150

Make sure to target the file and the activity's name properly.

Due to merge mode, android:exported="true" will be added to target activity element. This will replace the values if the it is already exist in the target element.

Source https://stackoverflow.com/questions/68678008

QUESTION

PHPickerViewController tapping on Search gets error... "Unable to load photos"

Asked 2022-Feb-10 at 17:27

I'm trying to implement a PHPickerViewController using SwiftUI and The Composable Architecture. (Not that I think that's particularly relevant but it might explain why some of my code is like it is).

Sample project

I've been playing around with this to try and work it out. I created a little sample Project on GitHub which removes The Composable Architecture and keeps the UI super simple.

https://github.com/oliverfoggin/BrokenImagePickers/tree/main

It looks like iOS 15 is breaking on both the UIImagePickerViewController and the PHPickerViewController. (Which makes sense as they both use the same UI under the hood).

I guess the nest step is to determine if the same error occurs when using them in a UIKit app.

My code

My code is fairly straight forward. It's pretty much just a reimplementation of the same feature that uses UIImagePickerViewController but I wanted to try with the newer APIs.

My code looks like this...

1public struct ImagePicker: UIViewControllerRepresentable {
2
3// Vars and setup stuff...
4  @Environment(\.presentationMode) var presentationMode
5
6  let viewStore: ViewStore<ImagePickerState, ImagePickerAction>
7  
8  public init(store: Store<ImagePickerState, ImagePickerAction>) {
9    self.viewStore = ViewStore(store)
10  }
11  
12// UIViewControllerRepresentable required functions
13  public func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> some UIViewController {
14
15    // Configuring the PHPickerViewController
16    var config = PHPickerConfiguration()
17    config.filter = PHPickerFilter.images
18    
19    let picker = PHPickerViewController(configuration: config)
20    picker.delegate = context.coordinator
21    return picker
22  }
23  
24  public func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
25  
26  public func makeCoordinator() -> Coordinator {
27    Coordinator(self)
28  }
29  
30// This is the coordinator that acts as the delegate
31  public class Coordinator: PHPickerViewControllerDelegate {
32    let parent: ImagePicker
33    
34    init(_ parent: ImagePicker) {
35      self.parent = parent
36    }
37    
38    public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
39      picker.dismiss(animated: true)
40      
41      guard let itemProvider = results.first?.itemProvider,
42        itemProvider.canLoadObject(ofClass: UIImage.self) else {
43        return
44      }
45      
46      itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, error in
47        if let image = image as? UIImage {
48          DispatchQueue.main.async {
49            self?.parent.viewStore.send(.imagePicked(image: image))
50          }
51        }
52      }
53    }
54  }
55}
56
All this works in the simple case

I can present the ImagePicker view and select a photo and it's all fine. I can cancel out of it ok. I can even scroll down the huge collection view of images that I have. I can even see the new image appear in my state object and display it within my app. (Note... this is still WIP and so the code is a bit clunky but that's only to get it working initially).

The problem case

The problem is that when I tap on the search bar in the PHPickerView (which is a search bar provided by Apple in the control, I didn't create it or code it). It seems to start to slide up the keyboard and then the view goes blank with a single message in the middle...

Unable to Load Photos

[Try Again]

I also get a strange looking error log. (I removed the time stamps to shorten the lines).

1public struct ImagePicker: UIViewControllerRepresentable {
2
3// Vars and setup stuff...
4  @Environment(\.presentationMode) var presentationMode
5
6  let viewStore: ViewStore<ImagePickerState, ImagePickerAction>
7  
8  public init(store: Store<ImagePickerState, ImagePickerAction>) {
9    self.viewStore = ViewStore(store)
10  }
11  
12// UIViewControllerRepresentable required functions
13  public func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> some UIViewController {
14
15    // Configuring the PHPickerViewController
16    var config = PHPickerConfiguration()
17    config.filter = PHPickerFilter.images
18    
19    let picker = PHPickerViewController(configuration: config)
20    picker.delegate = context.coordinator
21    return picker
22  }
23  
24  public func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
25  
26  public func makeCoordinator() -> Coordinator {
27    Coordinator(self)
28  }
29  
30// This is the coordinator that acts as the delegate
31  public class Coordinator: PHPickerViewControllerDelegate {
32    let parent: ImagePicker
33    
34    init(_ parent: ImagePicker) {
35      self.parent = parent
36    }
37    
38    public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
39      picker.dismiss(animated: true)
40      
41      guard let itemProvider = results.first?.itemProvider,
42        itemProvider.canLoadObject(ofClass: UIImage.self) else {
43        return
44      }
45      
46      itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, error in
47        if let image = image as? UIImage {
48          DispatchQueue.main.async {
49            self?.parent.viewStore.send(.imagePicked(image: image))
50          }
51        }
52      }
53    }
54  }
55}
56// These happen on immediately presenting the ImagePicker
57AppName[587:30596] [Picker] Showing picker unavailable UI (reason: still loading) with error: (null)
58AppName[587:30596] Writing analzed variants.
59
60
61// These happen when tapping the search bar
62AppName[587:30867] [lifecycle] [u A95D90FC-C77B-43CC-8FC6-C8E7C81DD22A:m (null)] [com.apple.mobileslideshow.photospicker(1.0)] Connection to plugin interrupted while in use.
63AppName[587:31002] [lifecycle] [u A95D90FC-C77B-43CC-8FC6-C8E7C81DD22A:m (null)] [com.apple.mobileslideshow.photospicker(1.0)] Connection to plugin invalidated while in use.
64AppName[587:30596] [Picker] Showing picker unavailable UI (reason: crashed) with error: (null)
65AppName[587:30596] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
66

Tapping the "Try Again" button reloads the initial scroll screen and I can carry on using it. But tapping the search bar again just shows the same error.

I'm usually the first one to point out that the error is almost definitely not with the Apple APIs but I'm stumped on this one. I'm not sure what it is that I'm doing that is causing this to happen?

Is it the fact that it's in a SwiftUI view?

Recreated the project in UIKit

I remade the same project using UIKit... https://github.com/oliverfoggin/UIKit-Image-Pickers

And I couldn't replicate the crash at all.

Also... if you are taking any sort of screen recording of the device the crash will not happen. I tried taking a recording on the device itself and couldn't replicate it. I also tried doing a movie recording from my Mac using the iPhone screen and couldn't replicate the crash. But... the instant I stopped the recording on QuickTime the crash was replicable again.

ANSWER

Answered 2021-Sep-26 at 14:32

Well.. this seems to be an iOS bug.

I have cerated a sample project here that shows the bug... https://github.com/oliverfoggin/BrokenImagePickers

And a replica project here written with UIKit that does not... https://github.com/oliverfoggin/UIKit-Image-Pickers

I tried to take a screen recording of this happening but it appears that if any screen recording is happening (whether on device or via QuickTime on the Mac) this suppresses the bug from happening.

I have filed a radar with Apple and sent them both projects to have a look at and LOTS of detail around what's happening. I'll keep this updated with any progress on that.

Hacky workaround

After a bit of further investigation I found that you can start with SwiftUI and then present a PHPickerViewController without this crash happening.

From SwiftUI if you present a UIViewControllerRepresentable... and then from there if you present the PHPickerViewController it will not crash.

So I came up with a (very tacky) workaround that avoids this crash.

I first create a UIViewController subclass that I use like a wrapper.

1public struct ImagePicker: UIViewControllerRepresentable {
2
3// Vars and setup stuff...
4  @Environment(\.presentationMode) var presentationMode
5
6  let viewStore: ViewStore<ImagePickerState, ImagePickerAction>
7  
8  public init(store: Store<ImagePickerState, ImagePickerAction>) {
9    self.viewStore = ViewStore(store)
10  }
11  
12// UIViewControllerRepresentable required functions
13  public func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> some UIViewController {
14
15    // Configuring the PHPickerViewController
16    var config = PHPickerConfiguration()
17    config.filter = PHPickerFilter.images
18    
19    let picker = PHPickerViewController(configuration: config)
20    picker.delegate = context.coordinator
21    return picker
22  }
23  
24  public func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
25  
26  public func makeCoordinator() -> Coordinator {
27    Coordinator(self)
28  }
29  
30// This is the coordinator that acts as the delegate
31  public class Coordinator: PHPickerViewControllerDelegate {
32    let parent: ImagePicker
33    
34    init(_ parent: ImagePicker) {
35      self.parent = parent
36    }
37    
38    public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
39      picker.dismiss(animated: true)
40      
41      guard let itemProvider = results.first?.itemProvider,
42        itemProvider.canLoadObject(ofClass: UIImage.self) else {
43        return
44      }
45      
46      itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, error in
47        if let image = image as? UIImage {
48          DispatchQueue.main.async {
49            self?.parent.viewStore.send(.imagePicked(image: image))
50          }
51        }
52      }
53    }
54  }
55}
56// These happen on immediately presenting the ImagePicker
57AppName[587:30596] [Picker] Showing picker unavailable UI (reason: still loading) with error: (null)
58AppName[587:30596] Writing analzed variants.
59
60
61// These happen when tapping the search bar
62AppName[587:30867] [lifecycle] [u A95D90FC-C77B-43CC-8FC6-C8E7C81DD22A:m (null)] [com.apple.mobileslideshow.photospicker(1.0)] Connection to plugin interrupted while in use.
63AppName[587:31002] [lifecycle] [u A95D90FC-C77B-43CC-8FC6-C8E7C81DD22A:m (null)] [com.apple.mobileslideshow.photospicker(1.0)] Connection to plugin invalidated while in use.
64AppName[587:30596] [Picker] Showing picker unavailable UI (reason: crashed) with error: (null)
65AppName[587:30596] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
66class WrappedPhotoPicker: UIViewController {
67  var picker: PHPickerViewController?
68  
69  override func viewDidLoad() {
70    super.viewDidLoad()
71    
72    if let picker = picker {
73      present(picker, animated: false)
74    }
75  }
76}
77

Then in the SwiftUI View I create this wrapper and set the picker in it.

1public struct ImagePicker: UIViewControllerRepresentable {
2
3// Vars and setup stuff...
4  @Environment(\.presentationMode) var presentationMode
5
6  let viewStore: ViewStore<ImagePickerState, ImagePickerAction>
7  
8  public init(store: Store<ImagePickerState, ImagePickerAction>) {
9    self.viewStore = ViewStore(store)
10  }
11  
12// UIViewControllerRepresentable required functions
13  public func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> some UIViewController {
14
15    // Configuring the PHPickerViewController
16    var config = PHPickerConfiguration()
17    config.filter = PHPickerFilter.images
18    
19    let picker = PHPickerViewController(configuration: config)
20    picker.delegate = context.coordinator
21    return picker
22  }
23  
24  public func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
25  
26  public func makeCoordinator() -> Coordinator {
27    Coordinator(self)
28  }
29  
30// This is the coordinator that acts as the delegate
31  public class Coordinator: PHPickerViewControllerDelegate {
32    let parent: ImagePicker
33    
34    init(_ parent: ImagePicker) {
35      self.parent = parent
36    }
37    
38    public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
39      picker.dismiss(animated: true)
40      
41      guard let itemProvider = results.first?.itemProvider,
42        itemProvider.canLoadObject(ofClass: UIImage.self) else {
43        return
44      }
45      
46      itemProvider.loadObject(ofClass: UIImage.self) { [weak self] image, error in
47        if let image = image as? UIImage {
48          DispatchQueue.main.async {
49            self?.parent.viewStore.send(.imagePicked(image: image))
50          }
51        }
52      }
53    }
54  }
55}
56// These happen on immediately presenting the ImagePicker
57AppName[587:30596] [Picker] Showing picker unavailable UI (reason: still loading) with error: (null)
58AppName[587:30596] Writing analzed variants.
59
60
61// These happen when tapping the search bar
62AppName[587:30867] [lifecycle] [u A95D90FC-C77B-43CC-8FC6-C8E7C81DD22A:m (null)] [com.apple.mobileslideshow.photospicker(1.0)] Connection to plugin interrupted while in use.
63AppName[587:31002] [lifecycle] [u A95D90FC-C77B-43CC-8FC6-C8E7C81DD22A:m (null)] [com.apple.mobileslideshow.photospicker(1.0)] Connection to plugin invalidated while in use.
64AppName[587:30596] [Picker] Showing picker unavailable UI (reason: crashed) with error: (null)
65AppName[587:30596] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
66class WrappedPhotoPicker: UIViewController {
67  var picker: PHPickerViewController?
68  
69  override func viewDidLoad() {
70    super.viewDidLoad()
71    
72    if let picker = picker {
73      present(picker, animated: false)
74    }
75  }
76}
77struct WrappedPickerView: UIViewControllerRepresentable {
78  @Environment(\.presentationMode) var presentationMode
79  @Binding var photoPickerResult: PHPickerResult?
80  
81  let wrappedPicker = WrappedPhotoPicker()
82  
83  func makeUIViewController(context: Context) -> WrappedPhotoPicker {
84    var config = PHPickerConfiguration()
85    config.filter = .images
86    config.selectionLimit = 1
87    
88    let picker = PHPickerViewController(configuration: config)
89    picker.delegate = context.coordinator
90    
91    wrappedPicker.picker = picker
92    return wrappedPicker
93  }
94  
95  func updateUIViewController(_ uiViewController: WrappedPhotoPicker, context: Context) {}
96  
97  func makeCoordinator() -> Coordinator {
98    Coordinator(self)
99  }
100  
101  class Coordinator: PHPickerViewControllerDelegate {
102    let parent: WrappedPickerView
103    
104    init(_ parent: WrappedPickerView) {
105      self.parent = parent
106    }
107    
108    func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
109      parent.presentationMode.wrappedValue.dismiss()
110      parent.wrappedPicker.dismiss(animated: false)
111      
112      parent.photoPickerResult = results.first
113    }
114  }
115}
116

This is far from ideal as I'm presenting at the wrong time and stuff. But it works until Apple provide a permanent fix for this.

Source https://stackoverflow.com/questions/69306179

QUESTION

Should I use %$% instead of %>%?

Asked 2022-Feb-08 at 23:14

Recently I have found the %$% pipe operator, but I am missing the point regarding its difference with %>% and if it could completely replace it.


Motivation to use %$%
  • The operator %$% could replace %>% in many cases:
1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5
  • Apparently, %$% is more usable than %>%:
1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5mtcars %>% plot(.$hp, .$mpg) # Does not work
6mtcars %$% plot(hp, mpg)     # Works
7
  • Implicitly fills the built-in data argument:
1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5mtcars %>% plot(.$hp, .$mpg) # Does not work
6mtcars %$% plot(hp, mpg)     # Works
7mtcars %>% lm(mpg ~ hp, data = .)
8mtcars %$% lm(mpg ~ hp)
9
  • Since % and $ are next to each other in the keyboard, inserting %$% is more convenient than inserting %>%.

Documentation

We find the following information in their respective help pages.

(?magrittr::`%>%`):

1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5mtcars %>% plot(.$hp, .$mpg) # Does not work
6mtcars %$% plot(hp, mpg)     # Works
7mtcars %>% lm(mpg ~ hp, data = .)
8mtcars %$% lm(mpg ~ hp)
9Description:
10
11     Pipe an object forward into a function or call expression.
12
13Usage:
14
15     lhs %>% rhs
16

(?magrittr::`%$%`):

1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5mtcars %>% plot(.$hp, .$mpg) # Does not work
6mtcars %$% plot(hp, mpg)     # Works
7mtcars %>% lm(mpg ~ hp, data = .)
8mtcars %$% lm(mpg ~ hp)
9Description:
10
11     Pipe an object forward into a function or call expression.
12
13Usage:
14
15     lhs %>% rhs
16Description:
17
18     Expose the names in ‘lhs’ to the ‘rhs’ expression. This is useful
19     when functions do not have a built-in data argument.
20
21Usage:
22
23     lhs %$% rhs
24

I was not able to understand the difference between the two pipe operators. Which is the difference between piping an object and exposing a name? But, in the rhs of %$%, we are able to get the piped object with the ., right?


Should I start using %$% instead of %>%? Which problems could I face doing so?

ANSWER

Answered 2022-Feb-08 at 23:14

In addition to the provided comments:

%$% also called the Exposition pipe vs. %>%:

This is a short summary of this article https://towardsdatascience.com/3-lesser-known-pipe-operators-in-tidyverse-111d3411803a

"The key difference in using %$% or %>% lies in the type of arguments of used functions."

One advantage, and as far as I can understand it, for me the only one to use %$% over %>% is the fact that we can avoid repetitive input of the dataframe name in functions that have no data as an argument.

For example the lm() has a data argument. In this case we can use both %>% and %$% interchangeable.

But in functions like the cor() which has no data argument:

1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5mtcars %>% plot(.$hp, .$mpg) # Does not work
6mtcars %$% plot(hp, mpg)     # Works
7mtcars %>% lm(mpg ~ hp, data = .)
8mtcars %$% lm(mpg ~ hp)
9Description:
10
11     Pipe an object forward into a function or call expression.
12
13Usage:
14
15     lhs %>% rhs
16Description:
17
18     Expose the names in ‘lhs’ to the ‘rhs’ expression. This is useful
19     when functions do not have a built-in data argument.
20
21Usage:
22
23     lhs %$% rhs
24mtcars %>% cor(disp, mpg) # Will give an Error
25
1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5mtcars %>% plot(.$hp, .$mpg) # Does not work
6mtcars %$% plot(hp, mpg)     # Works
7mtcars %>% lm(mpg ~ hp, data = .)
8mtcars %$% lm(mpg ~ hp)
9Description:
10
11     Pipe an object forward into a function or call expression.
12
13Usage:
14
15     lhs %>% rhs
16Description:
17
18     Expose the names in ‘lhs’ to the ‘rhs’ expression. This is useful
19     when functions do not have a built-in data argument.
20
21Usage:
22
23     lhs %$% rhs
24mtcars %>% cor(disp, mpg) # Will give an Error
25cor(mtcars$disp, mtcars$mpg)
26

is equivalent to

1mtcars %>% summary()
2mtcars %$% summary(.)
3mtcars %>% head(10)
4mtcars %$% head(.,10)
5mtcars %>% plot(.$hp, .$mpg) # Does not work
6mtcars %$% plot(hp, mpg)     # Works
7mtcars %>% lm(mpg ~ hp, data = .)
8mtcars %$% lm(mpg ~ hp)
9Description:
10
11     Pipe an object forward into a function or call expression.
12
13Usage:
14
15     lhs %>% rhs
16Description:
17
18     Expose the names in ‘lhs’ to the ‘rhs’ expression. This is useful
19     when functions do not have a built-in data argument.
20
21Usage:
22
23     lhs %$% rhs
24mtcars %>% cor(disp, mpg) # Will give an Error
25cor(mtcars$disp, mtcars$mpg)
26mtcars %$% cor(disp, mpg)
27

And note to use %$% pipe operator you have to load library(magrittr)

Update: on OPs comment: The pipe independent which one allows us to transform machine or computer language to a more readable human language.

ggplot2 is special. ggplot2 is not internally consistent. ggplot1 had a tidier API then ggplot2

Pipes would work with ggplot1: library(ggplot1) mtcars %>% ggplot(list( x= mpg, y = wt)) %>% ggpoint() %>% ggsave("mtcars.pdf", width= 8 height = 6)

In 2016 Wick Hadley said: "ggplot2 newver would have existed if I'd discovered the pipe 10 years earlier!" https://www.youtube.com/watch?v=K-ss_ag2k9E&list=LL&index=9

Source https://stackoverflow.com/questions/71008076

QUESTION

uploaded an APK which has an activity,activity alias,service or broadcast receiver with intentfilter, but without 'android : exported' property set

Asked 2022-Feb-03 at 10:56

I'm having an issue when i'm uploading app bundle to the play console that You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher. but my manifest file includes the property.

Manifest file

1    <?xml version="1.0" encoding="utf-8"?>
2    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3        package="**********">
4        <!-- io.flutter.app.FlutterApplication is an android.app.Application that
5             calls FlutterMain.startInitialization(this); in its onCreate method.
6             In most cases you can leave this as-is, but you if you want to provide
7             additional functionality it is fine to subclass or reimplement
8             FlutterApplication and put your custom class here. -->
9        <uses-permission android:name="android.permission.INTERNET" />
10        <uses-permission android:name="android.permission.CAMERA" />
11        <uses-feature android:name="android.hardware.camera" />
12        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
13        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
14        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
15        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
16        <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
17        <uses-permission android:name="android.permission.WAKE_LOCK"/>
18        <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
19        <uses-permission android:name="android.permission.VIBRATE" />
20        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
21        <uses-permission android:name="android.permission.WAKE_LOCK" />
22        <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
23        <uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
24    
25    
26        <application
27            android:name="io.flutter.app.FlutterApplication"
28            android:label="*****"
29            android:requestLegacyExternalStorage="true"
30            android:usesCleartextTraffic="true"
31            android:icon="@mipmap/ic_launcher">
32    
33    
34            <meta-data
35              android:name="com.google.firebase.messaging.default_notification_icon"
36              android:resource="@drawable/ic_stat_artboard_1" />
37    
38            <meta-data android:name="com.google.android.geo.API_KEY"
39                android:value="Z*********"/>
40    
41            <provider
42                android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
43                android:authorities="im.mingguang.mingguang_app.flutter_downloader.provider"
44                android:grantUriPermissions="true"
45                android:requestLegacyExternalStorage="true">
46                <meta-data
47                    android:name="android.support.FILE_PROVIDER_PATHS"
48                    android:resource="@xml/provider_paths"/>
49            </provider>
50    
51            <provider
52        android:name="androidx.core.content.FileProvider"
53        android:authorities="${applicationId}.provider"
54        android:grantUriPermissions="true">
55        <meta-data
56            android:name="android.support.FILE_PROVIDER_PATHS"
57            android:resource="@xml/provider_paths"/>
58    </provider>
59            <activity
60                android:name=".MainActivity"
61                android:launchMode="singleTop"
62                android:theme="@style/LaunchTheme"
63                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
64                android:hardwareAccelerated="true"
65                android:exported="true"
66                android:windowSoftInputMode="adjustResize">
67                <intent-filter>
68                    <action android:name="android.intent.action.MAIN"/>
69                    <category android:name="android.intent.category.DEFAULT"/>
70                    <category android:name="android.intent.category.LAUNCHER"/>
71                </intent-filter>
72                <intent-filter>
73                    <action android:name="FLUTTER_NOTIFICATION_CLICK" />
74                    <category android:name="android.intent.category.DEFAULT"/>
75                </intent-filter>
76            </activity>
77            <!-- Don't delete the meta-data below.
78                 This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
79            <meta-data
80                android:name="flutterEmbedding"
81                android:value="2" />
82        </application>
83    </manifest>
84

Play Console Error

enter image description here

ANSWER

Answered 2022-Jan-12 at 23:56

I face the same Issue but i solved by writing android:exported="true" in activity bellow the android:name=".MainActivity" image shown

Source https://stackoverflow.com/questions/70684516

QUESTION

Vue 3: Module '"../../node_modules/vue/dist/vue"' has no exported member

Asked 2022-Jan-24 at 08:38

After updating my npm packages, some of the imports from the 'vue' module started showing errors:

TS2305: Module '"../../node_modules/vue/dist/vue"' has no exported member 'X'

where X is nextTick, onMounted, ref, watch etc. When serving the project, Vue says it's "failed to compile". WebStorm actually recognizes the exports, suggests them and shows types, but the error is shown regardless. Some exports like computed and defineComponent work just fine.

What I've tried:

  • Rollback to the previously used Vue version "3.2.2" > "3.0.11". It makes the abovementioned type errors disappear, but the app stops working entirely, showing lots of TypeError: Object(...) is not a function errors in console and not rendering the app at all. In the terminal, some new warnings are introduced: "export 'X' (imported as '_X') was not found in 'vue' where X is createElementBlock, createElementVNode, normalizeClass and normalizeStyle.
  • Rollback other dependencies. None of the ones that I tried helped fix the problem, unfortunately.
  • Manually declare the entirety of 'vue' module. We can declare the 'vue' module exports in shims-vue.d.ts, and it actually makes the errors disappear, however, this seems like a terrible, time-consuming workaround, so I would opt out for a better solution if possible.

My full list of dependencies:

1"dependencies": {
2   "@capacitor/android": "3.0.0",
3   "@capacitor/app": "1.0.0",
4   "@capacitor/core": "3.0.0",
5   "@capacitor/haptics": "1.0.0",
6   "@capacitor/keyboard": "1.0.0",
7   "@capacitor/push-notifications": "^1.0.3",
8   "@google-pay/button-element": "^2.5.0",
9   "@ionic-native/core": "^5.34.0",
10   "@ionic-native/qr-scanner": "^5.35.0",
11   "@ionic-native/vibration": "^5.34.0",
12   "@ionic/vue": "^5.4.0",
13   "@ionic/vue-router": "^5.4.0",
14   "@j-t-mcc/vue3-chartjs": "^1.1.2",
15   "chart.js": "^3.4.1",
16   "chartjs-plugin-datalabels": "^2.0.0",
17   "color": "^3.1.3",
18   "cordova-plugin-background-mode": "^0.7.3",
19   "cordova-plugin-device": "^2.0.3",
20   "cordova-plugin-qrscanner": "^3.0.1",
21   "core-js": "^3.6.5",
22   "firebase": "^8.6.2",
23   "numeral": "^2.0.6",
24   "pug": "^3.0.2",
25   "pug-plain-loader": "^1.1.0",
26   "secure-ls": "^1.2.6",
27   "uuid": "^8.3.2",
28   "v-cupertino": "^1.2.4",
29   "vue": "^3.2.0",
30   "vue-chartjs": "^3.5.1",
31   "vue-i18n": "^9.1.3",
32   "vue-numerals": "^4.0.6",
33   "vue-router": "^4.0.0-0",
34   "vuex": "^4.0.1"
35 },
36 "devDependencies": {
37   "@capacitor/cli": "3.0.0",
38   "@types/jest": "^24.0.19",
39   "@types/uuid": "^8.3.1",
40   "@typescript-eslint/eslint-plugin": "^2.33.0",
41   "@typescript-eslint/parser": "^2.33.0",
42   "@vue/cli-plugin-babel": "~4.5.0",
43   "@vue/cli-plugin-e2e-cypress": "~4.5.0",
44   "@vue/cli-plugin-eslint": "^4.5.13",
45   "@vue/cli-plugin-router": "~4.5.0",
46   "@vue/cli-plugin-typescript": "~4.5.0",
47   "@vue/cli-plugin-unit-jest": "~4.5.0",
48   "@vue/cli-service": "~4.5.0",
49   "@vue/compiler-sfc": "^3.0.0-0",
50   "@vue/eslint-config-typescript": "^5.0.2",
51   "@vue/test-utils": "^2.0.0-0",
52   "eslint": "^6.7.2",
53   "eslint-plugin-vue": "^7.0.0-0",
54   "stylus": "^0.54.7",
55   "stylus-loader": "^3.0.2",
56   "typescript": "~3.9.3",
57   "vue-jest": "^5.0.0-0"
58 }
59

ANSWER

Answered 2021-Aug-15 at 13:53

That named exports from composition API are unavailable means that vue is Vue 2 at some place which has only default export. Since Vue 3 is in dependencies and both lock file and node_modules were refreshed, this means that Vue 2 is nested dependency of some direct dependency.

The problem needs to be investigated in lock file. It shows that @vue/cli-plugin-unit-jest@4.5.13 depends on vue-jest@3 which depends on vue@2.

A possible solution is to upgrade @vue/cli-plugin-unit-jest to the latest version, next. The same likely applies to other @vue/cli-* packages because they have matching versions.

Source https://stackoverflow.com/questions/68790790

QUESTION

Paramiko authentication fails with "Agreed upon 'rsa-sha2-512' pubkey algorithm" (and "unsupported public key algorithm: rsa-sha2-512" in sshd log)

Asked 2022-Jan-13 at 14:49

I have a Python 3 application running on CentOS Linux 7.7 executing SSH commands against remote hosts. It works properly but today I encountered an odd error executing a command against a "new" remote server (server based on RHEL 6.10):

encountered RSA key, expected OPENSSH key

Executing the same command from the system shell (using the same private key of course) works perfectly fine.

On the remote server I discovered in /var/log/secure that when SSH connection and commands are issued from the source server with Python (using Paramiko) sshd complains about unsupported public key algorithm:

userauth_pubkey: unsupported public key algorithm: rsa-sha2-512

Note that target servers with higher RHEL/CentOS like 7.x don't encounter the issue.

It seems like Paramiko picks/offers the wrong algorithm when negotiating with the remote server when on the contrary SSH shell performs the negotiation properly in the context of this "old" target server. How to get the Python program to work as expected?

Python code

1import paramiko
2import logging
3
4ssh_user = "my_user"
5ssh_keypath = "/path/to/.ssh/my_key.rsa"
6server = "server.tld"
7
8ssh_client = paramiko.SSHClient()
9ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
10ssh_client.connect(server,port=22,username=ssh_user, key_filename=ssh_keypath)  
11
12# SSH command
13cmd = "echo TEST : $(hostname)"
14
15stdin, stdout, stderr = ssh_client.exec_command(cmd, get_pty=True)
16exit_code = stdout.channel.recv_exit_status() 
17
18cmd_raw_output = stdout.readlines()
19out = "".join(cmd_raw_output)
20out_msg = out.strip()  
21
22# Ouput (logger code omitted)
23logger.debug(out_msg)
24
25if ssh_client is not None:
26    ssh_client.close()
27

Shell command equivalent

1import paramiko
2import logging
3
4ssh_user = "my_user"
5ssh_keypath = "/path/to/.ssh/my_key.rsa"
6server = "server.tld"
7
8ssh_client = paramiko.SSHClient()
9ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
10ssh_client.connect(server,port=22,username=ssh_user, key_filename=ssh_keypath)  
11
12# SSH command
13cmd = "echo TEST : $(hostname)"
14
15stdin, stdout, stderr = ssh_client.exec_command(cmd, get_pty=True)
16exit_code = stdout.channel.recv_exit_status() 
17
18cmd_raw_output = stdout.readlines()
19out = "".join(cmd_raw_output)
20out_msg = out.strip()  
21
22# Ouput (logger code omitted)
23logger.debug(out_msg)
24
25if ssh_client is not None:
26    ssh_client.close()
27ssh -i /path/to/.ssh/my_key.rsa my_user@server.tld "echo TEST : $(hostname)"   
28

Paramiko logs (DEBUG)

1import paramiko
2import logging
3
4ssh_user = "my_user"
5ssh_keypath = "/path/to/.ssh/my_key.rsa"
6server = "server.tld"
7
8ssh_client = paramiko.SSHClient()
9ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
10ssh_client.connect(server,port=22,username=ssh_user, key_filename=ssh_keypath)  
11
12# SSH command
13cmd = "echo TEST : $(hostname)"
14
15stdin, stdout, stderr = ssh_client.exec_command(cmd, get_pty=True)
16exit_code = stdout.channel.recv_exit_status() 
17
18cmd_raw_output = stdout.readlines()
19out = "".join(cmd_raw_output)
20out_msg = out.strip()  
21
22# Ouput (logger code omitted)
23logger.debug(out_msg)
24
25if ssh_client is not None:
26    ssh_client.close()
27ssh -i /path/to/.ssh/my_key.rsa my_user@server.tld "echo TEST : $(hostname)"   
28DEB [YYYYmmdd-HH:MM:30.475] thr=1   paramiko.transport: starting thread (client mode): 0xf6054ac8
29DEB [YYYYmmdd-HH:MM:30.476] thr=1   paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.9.1
30DEB [YYYYmmdd-HH:MM:30.490] thr=1   paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_5.3
31INF [YYYYmmdd-HH:MM:30.490] thr=1   paramiko.transport: Connected (version 2.0, client OpenSSH_5.3)
32DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: === Key exchange possibilities ===
33DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: kex algos: diffie-hellman-group-exchange-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1
34DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: server key: ssh-rsa, ssh-dss
35DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: client encrypt: aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se
36DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: server encrypt: aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se
37DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client mac: hmac-md5, hmac-sha1, umac-64@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-ripemd160, hmac-ripemd160@openssh.com, hmac-sha1-96, hmac-md5-96
38DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server mac: hmac-md5, hmac-sha1, umac-64@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-ripemd160, hmac-ripemd160@openssh.com, hmac-sha1-96, hmac-md5-96
39DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client compress: none, zlib@openssh.com
40DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server compress: none, zlib@openssh.com
41DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client lang: <none>
42DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server lang: <none>.
43DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: kex follows: False
44DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: === Key exchange agreements ===
45DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: Kex: diffie-hellman-group-exchange-sha256
46DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: HostKey: ssh-rsa
47DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: Cipher: aes128-ctr
48DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: MAC: hmac-sha2-256
49DEB [YYYYmmdd-HH:MM:30.501] thr=1   paramiko.transport: Compression: none
50DEB [YYYYmmdd-HH:MM:30.501] thr=1   paramiko.transport: === End of kex handshake ===
51DEB [YYYYmmdd-HH:MM:30.548] thr=1   paramiko.transport: Got server p (2048 bits)
52DEB [YYYYmmdd-HH:MM:30.666] thr=1   paramiko.transport: kex engine KexGexSHA256 specified hash_algo <built-in function openssl_sha256>
53DEB [YYYYmmdd-HH:MM:30.667] thr=1   paramiko.transport: Switch to new keys ...
54DEB [YYYYmmdd-HH:MM:30.669] thr=2   paramiko.transport: Adding ssh-rsa host key for server.tld: b'caea********************.'
55DEB [YYYYmmdd-HH:MM:30.674] thr=2   paramiko.transport: Trying discovered key b'b49c********************' in /path/to/.ssh/my_key.rsa
56DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: userauth is OK
57DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: Finalizing pubkey algorithm for key of type 'ssh-rsa'
58DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
59DEB [YYYYmmdd-HH:MM:30.723] thr=1   paramiko.transport: Server-side algorithm list: ['']
60DEB [YYYYmmdd-HH:MM:30.723] thr=1   paramiko.transport: Agreed upon 'rsa-sha2-512' pubkey algorithm
61INF [YYYYmmdd-HH:MM:30.735] thr=1   paramiko.transport: Authentication (publickey) failed.
62DEB [YYYYmmdd-HH:MM:30.739] thr=2   paramiko.transport: Trying SSH agent key b'9d37********************'
63DEB [YYYYmmdd-HH:MM:30.747] thr=1   paramiko.transport: userauth is OK.
64DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Finalizing pubkey algorithm for key of type 'ssh-rsa'
65DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
66DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Server-side algorithm list: ['']
67DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Agreed upon 'rsa-sha2-512' pubkey algorithm
68INF [YYYYmmdd-HH:MM:30.868] thr=1   paramiko.transport: Authentication (publickey) failed...
69

Shell command logs

1import paramiko
2import logging
3
4ssh_user = "my_user"
5ssh_keypath = "/path/to/.ssh/my_key.rsa"
6server = "server.tld"
7
8ssh_client = paramiko.SSHClient()
9ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
10ssh_client.connect(server,port=22,username=ssh_user, key_filename=ssh_keypath)  
11
12# SSH command
13cmd = "echo TEST : $(hostname)"
14
15stdin, stdout, stderr = ssh_client.exec_command(cmd, get_pty=True)
16exit_code = stdout.channel.recv_exit_status() 
17
18cmd_raw_output = stdout.readlines()
19out = "".join(cmd_raw_output)
20out_msg = out.strip()  
21
22# Ouput (logger code omitted)
23logger.debug(out_msg)
24
25if ssh_client is not None:
26    ssh_client.close()
27ssh -i /path/to/.ssh/my_key.rsa my_user@server.tld "echo TEST : $(hostname)"   
28DEB [YYYYmmdd-HH:MM:30.475] thr=1   paramiko.transport: starting thread (client mode): 0xf6054ac8
29DEB [YYYYmmdd-HH:MM:30.476] thr=1   paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.9.1
30DEB [YYYYmmdd-HH:MM:30.490] thr=1   paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_5.3
31INF [YYYYmmdd-HH:MM:30.490] thr=1   paramiko.transport: Connected (version 2.0, client OpenSSH_5.3)
32DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: === Key exchange possibilities ===
33DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: kex algos: diffie-hellman-group-exchange-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1
34DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: server key: ssh-rsa, ssh-dss
35DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: client encrypt: aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se
36DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: server encrypt: aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se
37DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client mac: hmac-md5, hmac-sha1, umac-64@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-ripemd160, hmac-ripemd160@openssh.com, hmac-sha1-96, hmac-md5-96
38DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server mac: hmac-md5, hmac-sha1, umac-64@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-ripemd160, hmac-ripemd160@openssh.com, hmac-sha1-96, hmac-md5-96
39DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client compress: none, zlib@openssh.com
40DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server compress: none, zlib@openssh.com
41DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client lang: <none>
42DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server lang: <none>.
43DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: kex follows: False
44DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: === Key exchange agreements ===
45DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: Kex: diffie-hellman-group-exchange-sha256
46DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: HostKey: ssh-rsa
47DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: Cipher: aes128-ctr
48DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: MAC: hmac-sha2-256
49DEB [YYYYmmdd-HH:MM:30.501] thr=1   paramiko.transport: Compression: none
50DEB [YYYYmmdd-HH:MM:30.501] thr=1   paramiko.transport: === End of kex handshake ===
51DEB [YYYYmmdd-HH:MM:30.548] thr=1   paramiko.transport: Got server p (2048 bits)
52DEB [YYYYmmdd-HH:MM:30.666] thr=1   paramiko.transport: kex engine KexGexSHA256 specified hash_algo <built-in function openssl_sha256>
53DEB [YYYYmmdd-HH:MM:30.667] thr=1   paramiko.transport: Switch to new keys ...
54DEB [YYYYmmdd-HH:MM:30.669] thr=2   paramiko.transport: Adding ssh-rsa host key for server.tld: b'caea********************.'
55DEB [YYYYmmdd-HH:MM:30.674] thr=2   paramiko.transport: Trying discovered key b'b49c********************' in /path/to/.ssh/my_key.rsa
56DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: userauth is OK
57DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: Finalizing pubkey algorithm for key of type 'ssh-rsa'
58DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
59DEB [YYYYmmdd-HH:MM:30.723] thr=1   paramiko.transport: Server-side algorithm list: ['']
60DEB [YYYYmmdd-HH:MM:30.723] thr=1   paramiko.transport: Agreed upon 'rsa-sha2-512' pubkey algorithm
61INF [YYYYmmdd-HH:MM:30.735] thr=1   paramiko.transport: Authentication (publickey) failed.
62DEB [YYYYmmdd-HH:MM:30.739] thr=2   paramiko.transport: Trying SSH agent key b'9d37********************'
63DEB [YYYYmmdd-HH:MM:30.747] thr=1   paramiko.transport: userauth is OK.
64DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Finalizing pubkey algorithm for key of type 'ssh-rsa'
65DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
66DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Server-side algorithm list: ['']
67DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Agreed upon 'rsa-sha2-512' pubkey algorithm
68INF [YYYYmmdd-HH:MM:30.868] thr=1   paramiko.transport: Authentication (publickey) failed...
69OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
70debug1: Reading configuration data /etc/ssh/ssh_config
71debug1: /etc/ssh/ssh_config line 58: Applying options for *
72debug2: resolving "server.tld" port 22
73debug2: ssh_connect_direct: needpriv 0
74debug1: Connecting to server.tld [server.tld] port 22.
75debug1: Connection established.
76debug1: permanently_set_uid: 0/0
77debug1: key_load_public: No such file or directory
78debug1: identity file /path/to/.ssh/my_key.rsa type -1
79debug1: key_load_public: No such file or directory
80debug1: identity file /path/to/.ssh/my_key.rsa-cert type -1
81debug1: Enabling compatibility mode for protocol 2.0
82debug1: Local version string SSH-2.0-OpenSSH_7.4
83debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
84debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
85debug2: fd 3 setting O_NONBLOCK
86debug1: Authenticating to server.tld:22 as 'my_user'
87debug3: hostkeys_foreach: reading file "/path/to/.ssh/known_hosts"
88debug3: record_hostkey: found key type RSA in file /path/to/.ssh/known_hosts:82
89debug3: load_hostkeys: loaded 1 keys from server.tld
90debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
91debug3: send packet: type 20
92debug1: SSH2_MSG_KEXINIT sent
93debug3: receive packet: type 20
94debug1: SSH2_MSG_KEXINIT received
95debug2: local client KEXINIT proposal
96debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
97debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss
98debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
99debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
100debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
101debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
102debug2: compression ctos: none,zlib@openssh.com,zlib
103debug2: compression stoc: none,zlib@openssh.com,zlib
104debug2: languages ctos:
105debug2: languages stoc:
106debug2: first_kex_follows 0
107debug2: reserved 0
108debug2: peer server KEXINIT proposal
109debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
110debug2: host key algorithms: ssh-rsa,ssh-dss
111debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
112debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
113debug2: MACs ctos: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
114debug2: MACs stoc: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
115debug2: compression ctos: none,zlib@openssh.com
116debug2: compression stoc: none,zlib@openssh.com
117debug2: languages ctos:
118debug2: languages stoc:
119debug2: first_kex_follows 0
120debug2: reserved 0
121debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
122debug1: kex: host key algorithm: ssh-rsa
123debug1: kex: server->client cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
124debug1: kex: client->server cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
125debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
126debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
127debug3: send packet: type 34
128debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
129debug3: receive packet: type 31
130debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
131debug2: bits set: 1502/3072
132debug3: send packet: type 32
133debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
134debug3: receive packet: type 33
135debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
136debug1: Server host key: ssh-.:**************************************************
137debug3: hostkeys_foreach: reading file "/path/to/.ssh/known_hosts"
138debug3: record_hostkey: found key type RSA in file /path/to/.ssh/known_hosts:8..2
139debug3: load_hostkeys: loaded 1 keys from server.tld
140debug1: Host 'server.tld' is known and matches the RSA host key.
141debug1: Found key in /path/to/.ssh/known_hosts:82
142debug2: bits set: 1562/3072
143debug3: send packet: type 21
144debug2: set_newkeys: mode 1
145debug1: rekey after 4294967296 blocks
146debug1: SSH2_MSG_NEWKEYS sent
147debug1: expecting SSH2_MSG_NEWKEYS
148debug3: receive packet: type 21
149debug1: SSH2_MSG_NEWKEYS received
150debug2: set_newkeys: mode 0
151debug1: rekey after 4294967296 blocks
152debug2: key: <foo> (0x55bcf6d1d320), agent
153debug2: key: /path/to/.ssh/my_key.rsa ((nil)), explicit
154debug3: send packet: type 5
155debug3: receive packet: type 6
156debug2: service_accept: ssh-userauth
157debug1: SSH2_MSG_SERVICE_ACCEPT received
158debug3: send packet: type 50
159debug3: receive packet: type 51
160debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
161debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
162debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
163debug3: authmethod_lookup gssapi-keyex
164debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
165debug3: authmethod_is_enabled gssapi-keyex
166debug1: Next authentication method: gssapi-keyex
167debug1: No valid Key exchange context
168debug2: we did not send a packet, disable method
169debug3: authmethod_lookup gssapi-with-mic
170debug3: remaining preferred: publickey,keyboard-interactive,password
171debug3: authmethod_is_enabled gssapi-with-mic
172debug1: Next authentication method: gssapi-with-mic
173debug1: Unspecified GSS failure.  Minor code may provide more information
174No Kerberos credentials available (default cache: KEYRING:persistent:0)
175
176debug1: Unspecified GSS failure.  Minor code may provide more information
177No Kerberos credentials available (default cache: KEYRING:persistent:0)
178
179debug2: we did not send a packet, disable method
180debug3: authmethod_lookup publickey
181debug3: remaining preferred: keyboard-interactive,password
182debug3: authmethod_is_enabled publickey
183debug1: Next authentication method: publickey
184debug1: Offering RSA public key: <foo>
185debug3: send_pubkey_test
186debug3: send packet: type 50
187debug2: we sent a publickey packet, wait for reply
188debug3: receive packet: type 51
189debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
190debug1: Trying private key: /path/to/.ssh/my_key.rsa
191debug3: sign_and_send_pubkey: RSA SHA256:**********************************
192debug3: send packet: type 50
193debug2: we sent a publickey packet, wait for reply
194debug3: receive packet: type 52
195debug1: Authentication succeeded (publickey).
196Authenticated to server.tld ([server.tld]:22).
197debug1: channel 0: new [client-session]
198debug3: ssh_session2_open: channel_new: 0
199debug2: channel 0: send open
200debug3: send packet: type 90
201debug1: Requesting no-more-sessions@openssh.com
202debug3: send packet: type 80
203debug1: Entering interactive session.
204debug1: pledge: network
205debug3: receive packet: type 91
206debug2: callback start
207debug2: fd 3 setting TCP_NODELAY
208debug3: ssh_packet_set_tos: set IP_TOS 0x08
209debug2: client_session2_setup: id 0
210debug1: Sending environment.
211debug3: Ignored env XDG_SESSION_ID
212debug3: Ignored env HOSTNAME
213debug3: Ignored env SELINUX_ROLE_REQUESTED
214debug3: Ignored env TERM
215debug3: Ignored env SHELL
216debug3: Ignored env HISTSIZE
217debug3: Ignored env SSH_CLIENT
218debug3: Ignored env SELINUX_USE_CURRENT_RANGE
219debug3: Ignored env SSH_TTY
220debug3: Ignored env CDPATH
221debug3: Ignored env USER
222debug3: Ignored env LS_COLORS
223debug3: Ignored env SSH_AUTH_SOCK
224debug3: Ignored env MAIL
225debug3: Ignored env PATH
226debug3: Ignored env PWD
227debug1: Sending env LANG = xx_XX.UTF-8
228debug2: channel 0: request env confirm 0
229debug3: send packet: type 98
230debug3: Ignored env SELINUX_LEVEL_REQUESTED
231debug3: Ignored env HISTCONTROL
232debug3: Ignored env SHLVL
233debug3: Ignored env HOME
234debug3: Ignored env LOGNAME
235debug3: Ignored env SSH_CONNECTION
236debug3: Ignored env LESSOPEN
237debug3: Ignored env XDG_RUNTIME_DIR
238debug3: Ignored env _
239debug1: Sending command: echo TEST : $(hostname)
240debug2: channel 0: request exec confirm 1
241debug3: send packet: type 98
242debug2: callback done
243debug2: channel 0: open confirm rwindow 0 rmax 32768
244debug2: channel 0: rcvd adjust 2097152
245debug3: receive packet: type 99
246debug2: channel_input_status_confirm: type 99 id 0
247debug2: exec request accepted on channel 0
248TEST : server.tld
249debug3: receive packet: type 96
250debug2: channel 0: rcvd eof
251debug2: channel 0: output open -> drain
252debug2: channel 0: obuf empty
253debug2: channel 0: close_write
254debug2: channel 0: output drain -> closed
255debug3: receive packet: type 98
256debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
257debug3: receive packet: type 98
258debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
259debug2: channel 0: rcvd eow
260debug2: channel 0: close_read
261debug2: channel 0: input open -> closed
262debug3: receive packet: type 97
263debug2: channel 0: rcvd close
264debug3: channel 0: will not send data after close
265debug2: channel 0: almost dead
266debug2: channel 0: gc: notify user
267debug2: channel 0: gc: user detached
268debug2: channel 0: send close
269debug3: send packet: type 97
270debug2: channel 0: is dead
271debug2: channel 0: garbage collecting
272debug1: channel 0: free: client-session, nchannels 1
273debug3: channel 0: status: The following connections are open:
274  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
275
276debug3: send packet: type 1
277Transferred: sent 3264, received 2656 bytes, in 0.0 seconds.
278Bytes per second: sent 92349.8, received 75147.4
279debug1: Exit status 0
280.
281

ANSWER

Answered 2022-Jan-13 at 14:49

Imo, it's a bug in Paramiko. It does not handle correctly absence of server-sig-algs extension on the server side.

Try disabling rsa-sha2-* on Paramiko side altogether:

1import paramiko
2import logging
3
4ssh_user = "my_user"
5ssh_keypath = "/path/to/.ssh/my_key.rsa"
6server = "server.tld"
7
8ssh_client = paramiko.SSHClient()
9ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
10ssh_client.connect(server,port=22,username=ssh_user, key_filename=ssh_keypath)  
11
12# SSH command
13cmd = "echo TEST : $(hostname)"
14
15stdin, stdout, stderr = ssh_client.exec_command(cmd, get_pty=True)
16exit_code = stdout.channel.recv_exit_status() 
17
18cmd_raw_output = stdout.readlines()
19out = "".join(cmd_raw_output)
20out_msg = out.strip()  
21
22# Ouput (logger code omitted)
23logger.debug(out_msg)
24
25if ssh_client is not None:
26    ssh_client.close()
27ssh -i /path/to/.ssh/my_key.rsa my_user@server.tld "echo TEST : $(hostname)"   
28DEB [YYYYmmdd-HH:MM:30.475] thr=1   paramiko.transport: starting thread (client mode): 0xf6054ac8
29DEB [YYYYmmdd-HH:MM:30.476] thr=1   paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.9.1
30DEB [YYYYmmdd-HH:MM:30.490] thr=1   paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_5.3
31INF [YYYYmmdd-HH:MM:30.490] thr=1   paramiko.transport: Connected (version 2.0, client OpenSSH_5.3)
32DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: === Key exchange possibilities ===
33DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: kex algos: diffie-hellman-group-exchange-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1
34DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: server key: ssh-rsa, ssh-dss
35DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: client encrypt: aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se
36DEB [YYYYmmdd-HH:MM:30.498] thr=1   paramiko.transport: server encrypt: aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se
37DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client mac: hmac-md5, hmac-sha1, umac-64@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-ripemd160, hmac-ripemd160@openssh.com, hmac-sha1-96, hmac-md5-96
38DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server mac: hmac-md5, hmac-sha1, umac-64@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-ripemd160, hmac-ripemd160@openssh.com, hmac-sha1-96, hmac-md5-96
39DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client compress: none, zlib@openssh.com
40DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server compress: none, zlib@openssh.com
41DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: client lang: <none>
42DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: server lang: <none>.
43DEB [YYYYmmdd-HH:MM:30.499] thr=1   paramiko.transport: kex follows: False
44DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: === Key exchange agreements ===
45DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: Kex: diffie-hellman-group-exchange-sha256
46DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: HostKey: ssh-rsa
47DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: Cipher: aes128-ctr
48DEB [YYYYmmdd-HH:MM:30.500] thr=1   paramiko.transport: MAC: hmac-sha2-256
49DEB [YYYYmmdd-HH:MM:30.501] thr=1   paramiko.transport: Compression: none
50DEB [YYYYmmdd-HH:MM:30.501] thr=1   paramiko.transport: === End of kex handshake ===
51DEB [YYYYmmdd-HH:MM:30.548] thr=1   paramiko.transport: Got server p (2048 bits)
52DEB [YYYYmmdd-HH:MM:30.666] thr=1   paramiko.transport: kex engine KexGexSHA256 specified hash_algo <built-in function openssl_sha256>
53DEB [YYYYmmdd-HH:MM:30.667] thr=1   paramiko.transport: Switch to new keys ...
54DEB [YYYYmmdd-HH:MM:30.669] thr=2   paramiko.transport: Adding ssh-rsa host key for server.tld: b'caea********************.'
55DEB [YYYYmmdd-HH:MM:30.674] thr=2   paramiko.transport: Trying discovered key b'b49c********************' in /path/to/.ssh/my_key.rsa
56DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: userauth is OK
57DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: Finalizing pubkey algorithm for key of type 'ssh-rsa'
58DEB [YYYYmmdd-HH:MM:30.722] thr=1   paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
59DEB [YYYYmmdd-HH:MM:30.723] thr=1   paramiko.transport: Server-side algorithm list: ['']
60DEB [YYYYmmdd-HH:MM:30.723] thr=1   paramiko.transport: Agreed upon 'rsa-sha2-512' pubkey algorithm
61INF [YYYYmmdd-HH:MM:30.735] thr=1   paramiko.transport: Authentication (publickey) failed.
62DEB [YYYYmmdd-HH:MM:30.739] thr=2   paramiko.transport: Trying SSH agent key b'9d37********************'
63DEB [YYYYmmdd-HH:MM:30.747] thr=1   paramiko.transport: userauth is OK.
64DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Finalizing pubkey algorithm for key of type 'ssh-rsa'
65DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
66DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Server-side algorithm list: ['']
67DEB [YYYYmmdd-HH:MM:30.748] thr=1   paramiko.transport: Agreed upon 'rsa-sha2-512' pubkey algorithm
68INF [YYYYmmdd-HH:MM:30.868] thr=1   paramiko.transport: Authentication (publickey) failed...
69OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
70debug1: Reading configuration data /etc/ssh/ssh_config
71debug1: /etc/ssh/ssh_config line 58: Applying options for *
72debug2: resolving "server.tld" port 22
73debug2: ssh_connect_direct: needpriv 0
74debug1: Connecting to server.tld [server.tld] port 22.
75debug1: Connection established.
76debug1: permanently_set_uid: 0/0
77debug1: key_load_public: No such file or directory
78debug1: identity file /path/to/.ssh/my_key.rsa type -1
79debug1: key_load_public: No such file or directory
80debug1: identity file /path/to/.ssh/my_key.rsa-cert type -1
81debug1: Enabling compatibility mode for protocol 2.0
82debug1: Local version string SSH-2.0-OpenSSH_7.4
83debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
84debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
85debug2: fd 3 setting O_NONBLOCK
86debug1: Authenticating to server.tld:22 as 'my_user'
87debug3: hostkeys_foreach: reading file "/path/to/.ssh/known_hosts"
88debug3: record_hostkey: found key type RSA in file /path/to/.ssh/known_hosts:82
89debug3: load_hostkeys: loaded 1 keys from server.tld
90debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
91debug3: send packet: type 20
92debug1: SSH2_MSG_KEXINIT sent
93debug3: receive packet: type 20
94debug1: SSH2_MSG_KEXINIT received
95debug2: local client KEXINIT proposal
96debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
97debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss
98debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
99debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
100debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
101debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
102debug2: compression ctos: none,zlib@openssh.com,zlib
103debug2: compression stoc: none,zlib@openssh.com,zlib
104debug2: languages ctos:
105debug2: languages stoc:
106debug2: first_kex_follows 0
107debug2: reserved 0
108debug2: peer server KEXINIT proposal
109debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
110debug2: host key algorithms: ssh-rsa,ssh-dss
111debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
112debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
113debug2: MACs ctos: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
114debug2: MACs stoc: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
115debug2: compression ctos: none,zlib@openssh.com
116debug2: compression stoc: none,zlib@openssh.com
117debug2: languages ctos:
118debug2: languages stoc:
119debug2: first_kex_follows 0
120debug2: reserved 0
121debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
122debug1: kex: host key algorithm: ssh-rsa
123debug1: kex: server->client cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
124debug1: kex: client->server cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
125debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
126debug1: kex: diffie-hellman-group-exchange-sha256 need=16 dh_need=16
127debug3: send packet: type 34
128debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
129debug3: receive packet: type 31
130debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
131debug2: bits set: 1502/3072
132debug3: send packet: type 32
133debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
134debug3: receive packet: type 33
135debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
136debug1: Server host key: ssh-.:**************************************************
137debug3: hostkeys_foreach: reading file "/path/to/.ssh/known_hosts"
138debug3: record_hostkey: found key type RSA in file /path/to/.ssh/known_hosts:8..2
139debug3: load_hostkeys: loaded 1 keys from server.tld
140debug1: Host 'server.tld' is known and matches the RSA host key.
141debug1: Found key in /path/to/.ssh/known_hosts:82
142debug2: bits set: 1562/3072
143debug3: send packet: type 21
144debug2: set_newkeys: mode 1
145debug1: rekey after 4294967296 blocks
146debug1: SSH2_MSG_NEWKEYS sent
147debug1: expecting SSH2_MSG_NEWKEYS
148debug3: receive packet: type 21
149debug1: SSH2_MSG_NEWKEYS received
150debug2: set_newkeys: mode 0
151debug1: rekey after 4294967296 blocks
152debug2: key: <foo> (0x55bcf6d1d320), agent
153debug2: key: /path/to/.ssh/my_key.rsa ((nil)), explicit
154debug3: send packet: type 5
155debug3: receive packet: type 6
156debug2: service_accept: ssh-userauth
157debug1: SSH2_MSG_SERVICE_ACCEPT received
158debug3: send packet: type 50
159debug3: receive packet: type 51
160debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
161debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
162debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
163debug3: authmethod_lookup gssapi-keyex
164debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
165debug3: authmethod_is_enabled gssapi-keyex
166debug1: Next authentication method: gssapi-keyex
167debug1: No valid Key exchange context
168debug2: we did not send a packet, disable method
169debug3: authmethod_lookup gssapi-with-mic
170debug3: remaining preferred: publickey,keyboard-interactive,password
171debug3: authmethod_is_enabled gssapi-with-mic
172debug1: Next authentication method: gssapi-with-mic
173debug1: Unspecified GSS failure.  Minor code may provide more information
174No Kerberos credentials available (default cache: KEYRING:persistent:0)
175
176debug1: Unspecified GSS failure.  Minor code may provide more information
177No Kerberos credentials available (default cache: KEYRING:persistent:0)
178
179debug2: we did not send a packet, disable method
180debug3: authmethod_lookup publickey
181debug3: remaining preferred: keyboard-interactive,password
182debug3: authmethod_is_enabled publickey
183debug1: Next authentication method: publickey
184debug1: Offering RSA public key: <foo>
185debug3: send_pubkey_test
186debug3: send packet: type 50
187debug2: we sent a publickey packet, wait for reply
188debug3: receive packet: type 51
189debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
190debug1: Trying private key: /path/to/.ssh/my_key.rsa
191debug3: sign_and_send_pubkey: RSA SHA256:**********************************
192debug3: send packet: type 50
193debug2: we sent a publickey packet, wait for reply
194debug3: receive packet: type 52
195debug1: Authentication succeeded (publickey).
196Authenticated to server.tld ([server.tld]:22).
197debug1: channel 0: new [client-session]
198debug3: ssh_session2_open: channel_new: 0
199debug2: channel 0: send open
200debug3: send packet: type 90
201debug1: Requesting no-more-sessions@openssh.com
202debug3: send packet: type 80
203debug1: Entering interactive session.
204debug1: pledge: network
205debug3: receive packet: type 91
206debug2: callback start
207debug2: fd 3 setting TCP_NODELAY
208debug3: ssh_packet_set_tos: set IP_TOS 0x08
209debug2: client_session2_setup: id 0
210debug1: Sending environment.
211debug3: Ignored env XDG_SESSION_ID
212debug3: Ignored env HOSTNAME
213debug3: Ignored env SELINUX_ROLE_REQUESTED
214debug3: Ignored env TERM
215debug3: Ignored env SHELL
216debug3: Ignored env HISTSIZE
217debug3: Ignored env SSH_CLIENT
218debug3: Ignored env SELINUX_USE_CURRENT_RANGE
219debug3: Ignored env SSH_TTY
220debug3: Ignored env CDPATH
221debug3: Ignored env USER
222debug3: Ignored env LS_COLORS
223debug3: Ignored env SSH_AUTH_SOCK
224debug3: Ignored env MAIL
225debug3: Ignored env PATH
226debug3: Ignored env PWD
227debug1: Sending env LANG = xx_XX.UTF-8
228debug2: channel 0: request env confirm 0
229debug3: send packet: type 98
230debug3: Ignored env SELINUX_LEVEL_REQUESTED
231debug3: Ignored env HISTCONTROL
232debug3: Ignored env SHLVL
233debug3: Ignored env HOME
234debug3: Ignored env LOGNAME
235debug3: Ignored env SSH_CONNECTION
236debug3: Ignored env LESSOPEN
237debug3: Ignored env XDG_RUNTIME_DIR
238debug3: Ignored env _
239debug1: Sending command: echo TEST : $(hostname)
240debug2: channel 0: request exec confirm 1
241debug3: send packet: type 98
242debug2: callback done
243debug2: channel 0: open confirm rwindow 0 rmax 32768
244debug2: channel 0: rcvd adjust 2097152
245debug3: receive packet: type 99
246debug2: channel_input_status_confirm: type 99 id 0
247debug2: exec request accepted on channel 0
248TEST : server.tld
249debug3: receive packet: type 96
250debug2: channel 0: rcvd eof
251debug2: channel 0: output open -> drain
252debug2: channel 0: obuf empty
253debug2: channel 0: close_write
254debug2: channel 0: output drain -> closed
255debug3: receive packet: type 98
256debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
257debug3: receive packet: type 98
258debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
259debug2: channel 0: rcvd eow
260debug2: channel 0: close_read
261debug2: channel 0: input open -> closed
262debug3: receive packet: type 97
263debug2: channel 0: rcvd close
264debug3: channel 0: will not send data after close
265debug2: channel 0: almost dead
266debug2: channel 0: gc: notify user
267debug2: channel 0: gc: user detached
268debug2: channel 0: send close
269debug3: send packet: type 97
270debug2: channel 0: is dead
271debug2: channel 0: garbage collecting
272debug1: channel 0: free: client-session, nchannels 1
273debug3: channel 0: status: The following connections are open:
274  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
275
276debug3: send packet: type 1
277Transferred: sent 3264, received 2656 bytes, in 0.0 seconds.
278Bytes per second: sent 92349.8, received 75147.4
279debug1: Exit status 0
280.
281ssh_client.connect(
282  server, username=ssh_user, key_filename=ssh_keypath,
283  disabled_algorithms=dict(pubkeys=["rsa-sha2-512", "rsa-sha2-256"]))
284

(note that there's no need to specify port=22, as that's the default)

I've found related Paramiko issue:
RSA key auth failing from paramiko 2.9.x client to dropbear server

Though it refers to Paramiko 2.9.0 change log, which seems to imply that the behavior is deliberate:

When the server does not send server-sig-algs, Paramiko will attempt the first algorithm in the above list. Clients connecting to legacy servers should thus use disabled_algorithms to turn off SHA2.


Since 2.9.2, Paramiko will say:

DEB [20220113-14:46:13.882] thr=1 paramiko.transport: Server did not send a server-sig-algs list; defaulting to our first preferred algo ('rsa-sha2-512')
DEB [20220113-14:46:13.882] thr=1 paramiko.transport: NOTE: you may use the 'disabled_algorithms' SSHClient/Transport init kwarg to disable that or other algorithms if your server does not support them!


Obligatory warning: Do not use AutoAddPolicy – You are losing a protection against MITM attacks by doing so. For a correct solution, see Paramiko "Unknown Server".


Your code for waiting for command to complete and reading its output is flawed too. See Wait to finish command executed with Python Paramiko. And for most purposes, the get_pty=True is not a good idea either.

Source https://stackoverflow.com/questions/70565357

QUESTION

Google Keyboard clipboard does not trigger a paste event

Asked 2022-Jan-12 at 16:36

I'm using a multi input component for capturing MFA codes. Think six identical boxes and as you type - it moves to the next one with an auto submit on completion.

We handle paste logic uniquely by filling in the code one at a time from the beginning which works really well and lets the user paste into any input field.

The issue is that when using a google keyboard (GBoard - native to Pixl phones) - the clipboard feature seems to not trigger an actual paste but instead tries to fire some sort of onChange event or series of onChange events.

So for instance if you have 123456 in your clipboard and you press the clipboard button, the change handler fires with "1" rather than an onPaste of "123456".

I was wondering if anyone had run into similar issues and how you navigated it. I've looked into the navigator.clipboard route - but this requires the user being prompted for permissions, and I would still need to uniquely identify the user keyboard since this would trigger for normal copy pastes (which work correctly)

ANSWER

Answered 2022-Jan-12 at 16:36

My coworker found out a solution to have specific handleChange behavior equal to the handlePaste behavior when e.target.value.length is equal to the codeLength (indicating a paste from gBoard in this instance). Hope this helps anyone else who may run into this issue.

Source https://stackoverflow.com/questions/70452313

QUESTION

Flutter resizeToAvoidBottomInset true not working with Expanded ListView

Asked 2022-Jan-10 at 08:46

The keyboard hides my ListView (GroupedListView). I think it's because of the Expanded Widget.

My body:

1Column(
2        children: [
3          Expanded(
4            child: Padding(
5              padding: const EdgeInsets.all(8.0),
6              child: GroupedListView<dynamic, String>(
7              controller: _scrollController,
8              keyboardDismissBehavior:
9                    ScrollViewKeyboardDismissBehavior.onDrag,
10              physics: const BouncingScrollPhysics(
11                    parent: AlwaysScrollableScrollPhysics()),
12              itemBuilder: (context, message) {
13                  return ListTile(
14                      title: ChatBubble(message),
15                  );
16                },
17              elements: messages,
18              groupBy: (message) => DateFormat('MMMM dd,yyyy')
19                    .format(message.timestamp.toDate()),
20              groupSeparatorBuilder: (String groupByValue) =>
21                    getMiddleChatBubble(context, groupByValue),
22              itemComparator: (item1, item2) =>
23                    item1.timestamp.compareTo(item2.timestamp),
24              useStickyGroupSeparators: false,
25              floatingHeader: false,
26              order: GroupedListOrder.ASC,
27              ),
28            ),
29          ),
30          WriteMessageBox(
31              group: group,
32              groupId: docs[0].id,
33              tokens: [widget.friendToken])
34        ],
35      );
36

enter image description here

Why the resizeToAvoidBottomInset isn't working?

I have opened an issue to the Flutter team

ANSWER

Answered 2022-Jan-04 at 11:41

It appears that you are using text fields so it hides data or sometimes it may overflow borders by black and yellow stripes

better to use SingleChildScrollView and for scrolling direction use scrollDirection with parameters Axis.vertical or Axis.horizontal

1Column(
2        children: [
3          Expanded(
4            child: Padding(
5              padding: const EdgeInsets.all(8.0),
6              child: GroupedListView<dynamic, String>(
7              controller: _scrollController,
8              keyboardDismissBehavior:
9                    ScrollViewKeyboardDismissBehavior.onDrag,
10              physics: const BouncingScrollPhysics(
11                    parent: AlwaysScrollableScrollPhysics()),
12              itemBuilder: (context, message) {
13                  return ListTile(
14                      title: ChatBubble(message),
15                  );
16                },
17              elements: messages,
18              groupBy: (message) => DateFormat('MMMM dd,yyyy')
19                    .format(message.timestamp.toDate()),
20              groupSeparatorBuilder: (String groupByValue) =>
21                    getMiddleChatBubble(context, groupByValue),
22              itemComparator: (item1, item2) =>
23                    item1.timestamp.compareTo(item2.timestamp),
24              useStickyGroupSeparators: false,
25              floatingHeader: false,
26              order: GroupedListOrder.ASC,
27              ),
28            ),
29          ),
30          WriteMessageBox(
31              group: group,
32              groupId: docs[0].id,
33              tokens: [widget.friendToken])
34        ],
35      );
36return SingleChildScrollView(
37      scrollDirection: Axis.vertical,
38      child :Column(
39        children: [
40          Expanded(
41            child: Padding(
42              padding: const EdgeInsets.all(8.0),
43              child: GroupedListView<dynamic, String>(
44              controller: _scrollController,
45              keyboardDismissBehavior:
46                    ScrollViewKeyboardDismissBehavior.onDrag,
47              physics: const BouncingScrollPhysics(
48                    parent: AlwaysScrollableScrollPhysics()),
49              itemBuilder: (context, message) {
50                  return ListTile(
51                      title: ChatBubble(message),
52                  );
53                },
54              elements: messages,
55              groupBy: (message) => DateFormat('MMMM dd,yyyy')
56                    .format(message.timestamp.toDate()),
57              groupSeparatorBuilder: (String groupByValue) =>
58                    getMiddleChatBubble(context, groupByValue),
59              itemComparator: (item1, item2) =>
60                    item1.timestamp.compareTo(item2.timestamp),
61              useStickyGroupSeparators: false,
62              floatingHeader: false,
63              order: GroupedListOrder.ASC,
64              ),
65            ),
66          ),
67          WriteMessageBox(
68              group: group,
69              groupId: docs[0].id,
70              tokens: [widget.friendToken])
71        ],
72      );
73
74
75);
76

Source https://stackoverflow.com/questions/70577942

QUESTION

Getting keyboard navigation to work with MUI Autocomplete and SimpleBar for react

Asked 2021-Dec-30 at 20:06

I am trying to add Simplebar scrollbar to the MUI Material Autocomplete component, instead of the default browser one. All works but doing that I've lost the ability to navigate the options list with the keyboard.

There is this snippet from the MUI docs

ListboxComponent If you provide a custom ListboxComponent prop, you need to make sure that the intended scroll container has the role attribute set to listbox. This ensures the correct behavior of the scroll, for example when using the keyboard to navigate.

But I have no idea how to do that.

The following code is from the MUI docs, first autocomplete example with custom ListboxComponenet and shortened movie list. (https://mui.com/components/autocomplete/)

1import * as React from 'react';
2import TextField from '@mui/material/TextField';
3import Autocomplete from '@mui/material/Autocomplete';
4
5import SimpleBar from "simplebar-react";
6import "simplebar/dist/simplebar.min.css";
7
8export default function ComboBox() {
9  return (
10    <Autocomplete
11      disablePortal
12      id="combo-box-demo"
13      options={top100Films}
14      ListboxComponent={SimpleBar}
15      sx={{ width: 300 }}
16      renderInput={(params) => <TextField {...params} label="Movie" />}
17    />
18  );
19}
20
21// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
22const top100Films = [
23  { label: 'City of God', year: 2002 },
24  { label: 'Se7en', year: 1995 },
25  { label: 'The Silence of the Lambs', year: 1991 },
26  { label: "It's a Wonderful Life", year: 1946 },
27  { label: 'Life Is Beautiful', year: 1997 },
28  { label: 'The Usual Suspects', year: 1995 },
29  { label: 'Léon: The Professional', year: 1994 },
30  { label: 'Spirited Away', year: 2001 },
31  { label: 'Saving Private Ryan', year: 1998 },
32  { label: 'Once Upon a Time in the West', year: 1968 },
33  { label: 'American History X', year: 1998 },
34  { label: 'Interstellar', year: 2014 },
35  { label: 'Casablanca', year: 1942 },
36  { label: 'City Lights', year: 1931 },
37  { label: 'Psycho', year: 1960 },
38  { label: 'The Green Mile', year: 1999 },
39  { label: 'The Intouchables', year: 2011 },
40  { label: 'Modern Times', year: 1936 },
41  { label: 'Raiders of the Lost Ark', year: 1981 },
42  { label: 'Rear Window', year: 1954 },
43  { label: 'The Pianist', year: 2002 },
44  { label: 'The Departed', year: 2006 },
45  { label: 'Terminator 2: Judgment Day', year: 1991 },
46  { label: 'Back to the Future', year: 1985 },
47  { label: 'Whiplash', year: 2014 },
48  { label: 'Gladiator', year: 2000 },
49  { label: 'Memento', year: 2000 },
50];
51

I have also tried the following but that also doesn't seem to work.

1import * as React from 'react';
2import TextField from '@mui/material/TextField';
3import Autocomplete from '@mui/material/Autocomplete';
4
5import SimpleBar from "simplebar-react";
6import "simplebar/dist/simplebar.min.css";
7
8export default function ComboBox() {
9  return (
10    <Autocomplete
11      disablePortal
12      id="combo-box-demo"
13      options={top100Films}
14      ListboxComponent={SimpleBar}
15      sx={{ width: 300 }}
16      renderInput={(params) => <TextField {...params} label="Movie" />}
17    />
18  );
19}
20
21// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
22const top100Films = [
23  { label: 'City of God', year: 2002 },
24  { label: 'Se7en', year: 1995 },
25  { label: 'The Silence of the Lambs', year: 1991 },
26  { label: "It's a Wonderful Life", year: 1946 },
27  { label: 'Life Is Beautiful', year: 1997 },
28  { label: 'The Usual Suspects', year: 1995 },
29  { label: 'Léon: The Professional', year: 1994 },
30  { label: 'Spirited Away', year: 2001 },
31  { label: 'Saving Private Ryan', year: 1998 },
32  { label: 'Once Upon a Time in the West', year: 1968 },
33  { label: 'American History X', year: 1998 },
34  { label: 'Interstellar', year: 2014 },
35  { label: 'Casablanca', year: 1942 },
36  { label: 'City Lights', year: 1931 },
37  { label: 'Psycho', year: 1960 },
38  { label: 'The Green Mile', year: 1999 },
39  { label: 'The Intouchables', year: 2011 },
40  { label: 'Modern Times', year: 1936 },
41  { label: 'Raiders of the Lost Ark', year: 1981 },
42  { label: 'Rear Window', year: 1954 },
43  { label: 'The Pianist', year: 2002 },
44  { label: 'The Departed', year: 2006 },
45  { label: 'Terminator 2: Judgment Day', year: 1991 },
46  { label: 'Back to the Future', year: 1985 },
47  { label: 'Whiplash', year: 2014 },
48  { label: 'Gladiator', year: 2000 },
49  { label: 'Memento', year: 2000 },
50];
51ListboxComponent={(props) => <SimpleBar {...props} role="listbox" />}
52

Any help would be appreciated, thanks.

ANSWER

Answered 2021-Dec-30 at 20:06

The problem is actually very complicated. Looking at its implementation, <SimpleBar /> doesn't pass either the React ref or the role prop to the correct element. The correct element I believe is .scrollbar-content, which is very deeply nested and basically untouchable.

ETA: In case you thought of getting cheesy with document.querySelectorAll setAttribute shenanigans, that will not work. The ref also needs to point at the correct element, and I don't think that's codeable on the workspace side.

The cleanest solution I can think of is to use Yarn 3 (👍) and patch simplebar-react yourself, passing the needed props to .scrollbar-content. Then you do:

1import * as React from 'react';
2import TextField from '@mui/material/TextField';
3import Autocomplete from '@mui/material/Autocomplete';
4
5import SimpleBar from &quot;simplebar-react&quot;;
6import &quot;simplebar/dist/simplebar.min.css&quot;;
7
8export default function ComboBox() {
9  return (
10    &lt;Autocomplete
11      disablePortal
12      id=&quot;combo-box-demo&quot;
13      options={top100Films}
14      ListboxComponent={SimpleBar}
15      sx={{ width: 300 }}
16      renderInput={(params) =&gt; &lt;TextField {...params} label=&quot;Movie&quot; /&gt;}
17    /&gt;
18  );
19}
20
21// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
22const top100Films = [
23  { label: 'City of God', year: 2002 },
24  { label: 'Se7en', year: 1995 },
25  { label: 'The Silence of the Lambs', year: 1991 },
26  { label: &quot;It's a Wonderful Life&quot;, year: 1946 },
27  { label: 'Life Is Beautiful', year: 1997 },
28  { label: 'The Usual Suspects', year: 1995 },
29  { label: 'Léon: The Professional', year: 1994 },
30  { label: 'Spirited Away', year: 2001 },
31  { label: 'Saving Private Ryan', year: 1998 },
32  { label: 'Once Upon a Time in the West', year: 1968 },
33  { label: 'American History X', year: 1998 },
34  { label: 'Interstellar', year: 2014 },
35  { label: 'Casablanca', year: 1942 },
36  { label: 'City Lights', year: 1931 },
37  { label: 'Psycho', year: 1960 },
38  { label: 'The Green Mile', year: 1999 },
39  { label: 'The Intouchables', year: 2011 },
40  { label: 'Modern Times', year: 1936 },
41  { label: 'Raiders of the Lost Ark', year: 1981 },
42  { label: 'Rear Window', year: 1954 },
43  { label: 'The Pianist', year: 2002 },
44  { label: 'The Departed', year: 2006 },
45  { label: 'Terminator 2: Judgment Day', year: 1991 },
46  { label: 'Back to the Future', year: 1985 },
47  { label: 'Whiplash', year: 2014 },
48  { label: 'Gladiator', year: 2000 },
49  { label: 'Memento', year: 2000 },
50];
51ListboxComponent={(props) =&gt; &lt;SimpleBar {...props} role=&quot;listbox&quot; /&gt;}
52const ListboxSimpleBar = React.forwardRef(function ListboxSimpleBar(props, ref) {
53  return &lt;SimpleBar {...props} role='listbox' listboxRef={ref} /&gt;
54}
55
56// ...
57ListboxComponent={ListboxSimpleBar}
58

The less clean solution is to fork the repo, patch it, and install it as a git dependency. Or publish to npm once you're sure it works and install as a regular dependency. That's the recommended method if you don't use Yarn 3 (👎). It's much more tedious and won't receive updates, but it is an option that exists.

The least clean solution is to copypasterino the simplebar-react code in your own workspace, edit it and import it in lieu of the real simplebar-react. Hackier, messier and funnier option 2, but only just barely.

Source https://stackoverflow.com/questions/70523261

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Keyboard

Tutorials and Learning Resources are not available at this moment for Keyboard

Share this Page

share link

Get latest updates on Keyboard