Kivy imports SDL2, GLEW and ANGLE when new process start - kivy

I need to use Python Multiprocessing for some CPU Bound task. When I run my app and new process is created I see in kivy log that it imports a kivy.deps and some more stuff again. It takes a lot of time and it looks like window is created again. Why is that happening? I expected the app to just create new process and do only what MyProcess class is for.
LOG
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\Patryk\PycharmProjects\pythonProject\Random\venv_python\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)]
[INFO ] [Python ] Interpreter at "C:\Users\Patryk\PycharmProjects\pythonProject\Random\venv_python\Scripts\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 NVIDIA 441.66'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'NVS 510/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 NVIDIA'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Base ] Start application main loop
[**IMPORTING DEPS AGAIN**]
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\Patryk\PycharmProjects\pythonProject\Random\venv_python\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)]
[INFO ] [Python ] Interpreter at "C:\Users\Patryk\PycharmProjects\pythonProject\Random\venv_python\Scripts\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
MP RUN
[INFO ] [WindowSDL ] exiting mainloop and closing.
[INFO ] [Base ] Leaving application in progress...
Process finished with exit code 0
MY CODE
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout
from multiprocessing import Process
kv = '''
MyWindow:
'''
class MyProcess(Process):
def __init__(self):
super().__init__()
def run(self):
print('MP RUN')
class MyWindow(BoxLayout):
def __init__(self, *args, **kwargs):
super().__init__(**kwargs)
mp = MyProcess()
mp.start()
class MyApp(App):
def build(self):
return Builder.load_string(kv)
if __name__ == '__main__':
MyApp().run()

I'm not sure offhand exactly what the new process inherits, but in this case you're clearly using it to run Python code that includes your kivy imports. Maybe you should use a separate file that doesn't include the imports you don't want, but I'm not sure what is the intention. The multiprocessing documentation may say something about the best way to avoid it.

Related

How do I force dependencies into separate chunks using manualChunk?

manualChunks: {
'#dnd-kit/core': [
'#dnd-kit/core',
'#dnd-kit/sortable',
'#dnd-kit/utilities',
],
'#radix-ui/react-collapsible': [
'#radix-ui/react-collapsible',
'#radix-ui/react-dropdown-menu',
'#radix-ui/react-navigation-menu',
],
react: ['react', 'react-dom'],
'react-aria': [
'#react-aria/checkbox',
'#react-aria/dialog',
'#react-aria/focus',
'#react-aria/meter',
'#react-aria/visually-hidden',
'#react-aria/utils',
'#react-aria/tooltip',
'#react-aria/overlays',
'#react-aria/radio',
],
'react-stately': [
'#react-stately/radio',
'#react-stately/toggle',
'#react-stately/checkbox',
],
slate: [
'#contra/slate',
'slate',
'slate-react',
'slate-history',
'slate-hyperscript',
],
'stream-chat': ['stream-chat', 'stream-chat-react'],
stripe: ['#stripe/react-stripe-js', '#stripe/stripe-js'],
visx: [
'#visx/curve',
'#visx/event',
'#visx/gradient',
'#visx/responsive',
'#visx/scale',
'#visx/shape',
'#visx/tooltip',
],
},
The above is my rollupjs manualChunk configuration.
Based on this configuration, I would expect to have several chunks that group together these dependencies.
However, almost everything ends up in stream-chat chunk.
What's happening and how do I achieve the desired result?

Swift password validation using REGEX [duplicate]

I am working on a Swift project and I need to use this regex to check email is valid or not but when the app start the checking the app crash and give me this error:
NSInternalInconsistencyException', reason: 'Can't do regex matching, reason: Can't open pattern U_REGEX_MISSING_CLOSE_BRACKET
This is my REGEX:
^(([^<>()[\\]\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+[\\.]*)+[a-zA-Z]{2,}))$
Check unescaped brackets in your regex pattern:
let pattern
= "^(([^<>()[\\]\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))"
// [ [ ] [ [ ]
+ "#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+[\\.]*)+[a-zA-Z]{2,}))$"
// [ ] [ ] [ ] [ ] [ ] [ ] [ ]
You have some mismatching brackets [ ] in the first half of your pattern.
In some dialects of regex, you have no need to escape [ between [ and ], but in some other dialects, you need it.
Try adding some escapes to your regex:
let pattern
= "^(([^<>()\\[\\]\\.,;:\\s#\\\"]+(\\.[^<>()\\[\\]\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))"
// [ ^^ ] [ ^^ ]
+ "#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+[\\.]*)+[a-zA-Z]{2,}))$"
// [ ] [ ] [ ] [ ] [ ] [ ] [ ]

Device Tree Bad Data (for PocketBeagle)

I am trying to create a device tree overlay for the PocketBeagle to interface to the MCP3204 ADC. I am trying to use the driver that exists already in the Linux kernel. My device tree source is the following:
/dts-v1/;
/plugin/;
/ {
compatible = "ti,am335x-pocketbeagle";
part-number = "mm-cape";
version = "00A0";
fragment#0 {
target = <&am33xx_pinmux>;
__overlay__ {
mm_chipselect: MM_CHIP_SELECT_PIN {
pinctrl-single,pin = <0xe8 0xf>;
};
};
};
fragment#1 {
target = <&ocp>;
__overlay__ {
mm_chipselect_helper: helper {
compatible = "bone-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&mm_chipselect>;
status = "okay";
};
};
};
fragment#2 {
target = <&spi0>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
cs-gpios = <&gpio2 24 0>, <0>, <0>, <0>;
mcp320x: mcp320x#0 {
compatible = "microchip,mcp3208";
reg = <0>;
spi-max-frequency = <1000000>;
};
};
};
};
When I load my device tree overlay I get the following output from dmesg:
[ 2.157460] pinctrl-single 44e10800.pinmux: bad data for mux MM_CHIP_SELECT_PIN
[ 2.164916] pinctrl-single 44e10800.pinmux: no pins entries for MM_CHIP_SELECT_PIN
[ 2.172687] pinctrl-single 44e10800.pinmux: bad data for mux MM_CHIP_SELECT_PIN
[ 2.180072] pinctrl-single 44e10800.pinmux: no pins entries for MM_CHIP_SELECT_PIN
[ 2.187700] bone-pinmux-helper ocp:helper: Failed to get pinctrl
[ 2.193762] ------------[ cut here ]------------
[ 2.193783] WARNING: CPU: 0 PID: 1 at drivers/base/devres.c:888 devm_kfree+0x4c/0x50()
[ 2.193791] Modules linked in:
[ 2.193810] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.4.91-ti-r133 #1
[ 2.193818] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 2.193862] [<c001bed0>] (unwind_backtrace) from [<c0015978>] (show_stack+0x20/0x24)
[ 2.193885] [<c0015978>] (show_stack) from [<c05c1674>] (dump_stack+0x8c/0xa0)
[ 2.193905] [<c05c1674>] (dump_stack) from [<c004435c>] (warn_slowpath_common+0x94/0xc4)
[ 2.193919] [<c004435c>] (warn_slowpath_common) from [<c0044490>] (warn_slowpath_null+0x2c/0x34)
[ 2.193932] [<c0044490>] (warn_slowpath_null) from [<c0718418>] (devm_kfree+0x4c/0x50)
[ 2.193951] [<c0718418>] (devm_kfree) from [<c073bea8>] (bone_pinmux_helper_probe+0x1c4/0x260)
[ 2.193966] [<c073bea8>] (bone_pinmux_helper_probe) from [<c0716368>] (platform_drv_probe+0x60/0xc0)
[ 2.193990] [<c0716368>] (platform_drv_probe) from [<c0713fcc>] (driver_probe_device+0x234/0x470)
[ 2.194005] [<c0713fcc>] (driver_probe_device) from [<c07142a4>] (__driver_attach+0x9c/0xa0)
[ 2.194020] [<c07142a4>] (__driver_attach) from [<c0711a80>] (bus_for_each_dev+0x8c/0xd0)
[ 2.194035] [<c0711a80>] (bus_for_each_dev) from [<c0713728>] (driver_attach+0x2c/0x30)
[ 2.194049] [<c0713728>] (driver_attach) from [<c0713200>] (bus_add_driver+0x1b8/0x278)
[ 2.194062] [<c0713200>] (bus_add_driver) from [<c0714d94>] (driver_register+0x88/0x104)
[ 2.194075] [<c0714d94>] (driver_register) from [<c0716274>] (__platform_driver_register+0x50/0x58)
[ 2.194094] [<c0716274>] (__platform_driver_register) from [<c0f96218>] (bone_pinmux_helper_driver_init+0x1c/0x20)
[ 2.194113] [<c0f96218>] (bone_pinmux_helper_driver_init) from [<c00098e4>] (do_one_initcall+0xd8/0x228)
[ 2.194133] [<c00098e4>] (do_one_initcall) from [<c0f4c000>] (kernel_init_freeable+0x1ec/0x288)
[ 2.194152] [<c0f4c000>] (kernel_init_freeable) from [<c0aa4314>] (kernel_init+0x1c/0xf8)
[ 2.194172] [<c0aa4314>] (kernel_init) from [<c0010e00>] (ret_from_fork+0x14/0x34)
[ 2.194217] ---[ end trace 20e7a3ce9aa45d9c ]---
[ 2.194310] bone-pinmux-helper: probe of ocp:helper failed with error -22
[ 2.222490] spi spi1.0: failed to request gpio
[ 2.227072] omap2_mcspi 48030000.spi: can't setup spi1.0, status -16
[ 2.233483] spi_master spi1: spi_device register error /ocp/spi#48030000/mcp320x#0
[ 2.241309] spi_master spi1: Failed to create SPI device for /ocp/spi#48030000/mcp320x#0
I can't seem to find what the source of the error could be. I have confirmed using multiple other examples that the structure of the file should be correct, and that the pin offset and mux value are correct. What could be causing this error?

Simple Kivy app crashes (release unlocked lock)

I am getting the following error when trying to run even the simplest of Kivy apps:
C:\Users\kprice\Desktop>python test.py
[INFO ] [Logger ] Record log in C:\Users\kprice\AppData\Roaming\SPB_16.6\.kivy\logs\kivy_17-03-03_57.txt
[INFO ] [Kivy ] v1.9.2.dev0, git-9f2daa0, 20170302
[INFO ] [Python ] v3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)]
[INFO ] [Factory ] 193 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.3.0 - Build 10.18.15.4256'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) HD Graphics 4400'>
[INFO ] [GL ] OpenGL parsed version: 4, 3
[INFO ] [GL ] Shading version <b'4.30 - Build 10.18.15.4256'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Shader ] fragment shader: <b"WARNING: 0:6: '' : #version directive missing">
[INFO ] [Shader ] vertex shader: <b"WARNING: 0:6: '' : #version directive missing">
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
Traceback (most recent call last):
File "test.py", line 13, in <module>
MyApp().run()
File "C:\Users\kprice\AppData\Local\Programs\Python\Python36\lib\site-packages\kivy\app.py", line 802, in run
root = self.build()
File "test.py", line 10, in build
return Label(text='Hello world')
File "C:\Users\kprice\AppData\Local\Programs\Python\Python36\lib\site-packages\kivy\uix\label.py", line 291, in __init__
self._trigger_texture()
File "kivy\_clock.pyx", line 75, in kivy._clock.ClockEvent.__call__ (kivy\_clock.c:2223)
RuntimeError: release unlocked lock
The code for the app is as follows:
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
Any ideas on why even the most basic program seems to crash?
That was a typo for a change in the kivy.clock code. It basically called the method twice, which it shouldn't (no thread lock to release).
I'm not sure if it's because of Cython or because of Windows, but I believe that error should return a ThreadError. There is too small amount of RuntimeErrors in Kivy, so I'm not sure why does it return a wrong type of error.

How to encode a POST Policy in golang - browser based uploads to amazon S3?

I am trying to upload a image file to amazon s3. The setup is as follows:
Web server: golangFront-end: simple html form for testing
In reference with this document : http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
I referred to the example provided in the above document and tried this: http://play.golang.org/p/3zn5fSDasK
package main
import "fmt"
import "encoding/base64"
func main() {
bytePolicy := []byte(`{
"expiration": "2013-08-06T12:00:00.000Z",
"conditions": [
{"bucket": "examplebucket"},
["starts-with", "$key", "user/user1/"],
{"acl": "public-read"},
{"success_action_redirect": "http://acl6.s3.amazonaws.com/successful_upload.html"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-meta-uuid": "14365123651274"},
["starts-with", "$x-amz-meta-tag", ""],
{"x-amz-credential":"AKIAIOSFODNN7EXAMPLE/20130806/us-east-1/s3/aws4_request"},
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-date": "20130806T000000Z" }
]
}`)
fmt.Println(base64.StdEncoding.EncodeToString(bytePolicy))
}
The result I got with this
eyAKICAgICAgICAgICAgICAgICAgICAgICAgImV4cGlyYXRpb24iOiAiMjAxMy0wOC0wNlQxMjowMDowMC4wMDBaIiwKICAgICAgICAgICAgICAgICAgICAgICAgImNvbmRpdGlvbnMiOiBbCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsiYnVja2V0IjogImV4YW1wbGVidWNrZXQifSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAidXNlci91c2VyMS8iXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyJhY2wiOiAicHVibGljLXJlYWQifSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyJzdWNjZXNzX2FjdGlvbl9yZWRpcmVjdCI6ICJodHRwOi8vYWNsNi5zMy5hbWF6b25hd3MuY29tL3N1Y2Nlc3NmdWxfdXBsb2FkLmh0bWwifSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbInN0YXJ0cy13aXRoIiwgIiRDb250ZW50LVR5cGUiLCAiaW1hZ2UvIl0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyJ4LWFtei1tZXRhLXV1aWQiOiAiMTQzNjUxMjM2NTEyNzQifSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbInN0YXJ0cy13aXRoIiwgIiR4LWFtei1tZXRhLXRhZyIsICIiXSwKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyJ4LWFtei1jcmVkZW50aWFsIjoiQUtJQUlPU0ZPRE5ON0VYQU1QTEUvMjAxMzA4MDYvdXMtZWFzdC0xL3MzL2F3czRfcmVxdWVzdCJ9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsieC1hbXotYWxnb3JpdGhtIjogIkFXUzQtSE1BQy1TSEEyNTYifSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsieC1hbXotZGF0ZSI6ICIyMDEzMDgwNlQwMDAwMDBaIiB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgXQogICAgICAgICAgICAgICAgICAgIH0=
The base 64 encoded policy which is on link of amazon tutorial:
eyAiZXhwaXJhdGlvbiI6ICIyMDEzLTA4LTA3VDEyOjAwOjAwLjAwMFoiLA0KICAiY29uZGl0aW9ucyI6IFsNCiAgICB7ImJ1Y2tldCI6ICJleGFtcGxlYnVja2V0In0sDQogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInVzZXIvdXNlcjEvIl0sDQogICAgeyJhY2wiOiAicHVibGljLXJlYWQifSwNCiAgICB7InN1Y2Nlc3NfYWN0aW9uX3JlZGlyZWN0IjogImh0dHA6Ly9leGFtcGxlYnVja2V0LnMzLmFtYXpvbmF3cy5jb20vc3VjY2Vzc2Z1bF91cGxvYWQuaHRtbCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJENvbnRlbnQtVHlwZSIsICJpbWFnZS8iXSwNCiAgICB7IngtYW16LW1ldGEtdXVpZCI6ICIxNDM2NTEyMzY1MTI3NCJ9LA0KICAgIFsic3RhcnRzLXdpdGgiLCAiJHgtYW16LW1ldGEtdGFnIiwgIiJdLA0KDQogICAgeyJ4LWFtei1jcmVkZW50aWFsIjogIkFLSUFJT1NGT0ROTjdFWEFNUExFLzIwMTMwODA2L3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QifSwNCiAgICB7IngtYW16LWFsZ29yaXRobSI6ICJBV1M0LUhNQUMtU0hBMjU2In0sDQogICAgeyJ4LWFtei1kYXRlIjogIjIwMTMwODA2VDAwMDAwMFoiIH0NCiAgXQ0KfQ==
Why my base64 encoded policy doesn't match with that of Amazon's?
Simply because the 2 JSON source texts which produce those base64 strings have different indentation and different content as seen below (they are not equal char-by-char).
Decode both of the base64 strings, and you will see the differences. You can do that either with a program (not necessarily Go), or simply use an online service like this one.
You shouldn't worry about indentation, it doesn't matter in JSON. But when you encode a text using Base64, that encodes all characters of the source including spaces and tabs used to indent, so different indentation will result in different Base64 encoded forms.
But comparing the 2 decoded JSON, there are also other differences:
First one:
"expiration": "2013-08-06T12:00:00.000Z"
"success_action_redirect": "http://acl6.s3.amazonaws.com/successful_upload.html"
2nd one:
"expiration": "2013-08-07T12:00:00.000Z"
"success_action_redirect": "http://examplebucket.s3.amazonaws.com/successful_upload.html"
The complete decoded JSON texts:
The first one:
{
"expiration": "2013-08-06T12:00:00.000Z",
"conditions": [
{"bucket": "examplebucket"},
["starts-with", "$key", "user/user1/"],
{"acl": "public-read"},
{"success_action_redirect": "http://acl6.s3.amazonaws.com/successful_upload.html"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-meta-uuid": "14365123651274"},
["starts-with", "$x-amz-meta-tag", ""],
{"x-amz-credential":"AKIAIOSFODNN7EXAMPLE/20130806/us-east-1/s3/aws4_request"},
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-date": "20130806T000000Z" }
]
}
And the 2nd one:
{ "expiration": "2013-08-07T12:00:00.000Z",
"conditions": [
{"bucket": "examplebucket"},
["starts-with", "$key", "user/user1/"],
{"acl": "public-read"},
{"success_action_redirect": "http://examplebucket.s3.amazonaws.com/successful_upload.html"},
["starts-with", "$Content-Type", "image/"],
{"x-amz-meta-uuid": "14365123651274"},
["starts-with", "$x-amz-meta-tag", ""],
{"x-amz-credential": "AKIAIOSFODNN7EXAMPLE/20130806/us-east-1/s3/aws4_request"},
{"x-amz-algorithm": "AWS4-HMAC-SHA256"},
{"x-amz-date": "20130806T000000Z" }
]
}

Resources