问:
Pass value in a REGEXP expression MySQL, MariaDB
Having this field in my database "description":

```<code><ul>
<li><a href="https://onedomain.com/whatever-18-8433290610079.html">Product 1 </a></li>
<li><a href="https://onedomain.com/whatever-15-8433290610079.html">Product 2</a></li>
</ul>
</code>```

I want to update it to this (notice categoryName of IdProduct):

```<code><ul>
<li><a href="https://newdomain.com/categoryName_IdProduct18/18-whatever-8433290610079.html">Product 1</a></li>
<li><a href="https://newdomain.com/categoryName_IdProduct15/15-whatever-8433290610079.html">Product 2</a></li>
</ul>
</code>```

I have this query that picks up the pattern correctly (IdProduct = this patter ([0-9]{1,5}) ) and the IdProduct correctly (second '\2') , the problem comes when making the subquery inside the concat expression since it doesn't pick up the value of IdProduct correctly ((first '\2') in subquery).
It works if I put a literal value. For example 1.
WHERE p3.id_product = 1

Here is my code:

```<code>UPDATE ps_product_lang pl
LEFT JOIN ps_product p ON (p.id_product = pl.id_product)
LEFT JOIN ps_category_lang cl2 ON (p.id_category_default = cl2.id_category)
SET pl.description = REGEXP_REPLACE(pl.description, '<a href="https://onedomain.com/(.*)-([0-9]{1,5})(?:-.*.html|.html)', CONCAT('<a href="https://newdomain.com/'
, Replace((SELECT LOWER(cl3.name) FROM ps_product p3 LEFT JOIN ps_category_lang cl3 ON (cl3.id_category = p3.id_category_default) WHERE p3.id_product = '\\2'), ' ', '-') , '/' , '\\2', '-' , Replace(LOWER(pl.name), ' ', '-') , '.html'))
</code>```

I have already tried with this and it does not work for me:
WHERE p3.id_product = CAST('\\2' AS UNSIGNED)

Here I show the structure of the table in case it helps.
Product
Product table

Product_lang
Product_lang table

Category_lang
category_lang table

Here is my output for this specific case if I put a literal value for idProduct. Example idProduct = 1. It correctly returns the name of the category (categoryId = 4).

```<code><li><a href="newdomain.com/men/18-whatever.html">Product 1</a></li>
<li><a href="newdomain.com/men/15-whatever.html">Product 2</a></li>
</code>```

I can show you the query SHOW CREATE TABLE of the tables involved. They are the Prestashop tables:

```<code>ps_product  CREATE TABLE `ps_product` (
  `id_product` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_supplier` int(10) unsigned DEFAULT NULL,
  `id_manufacturer` int(10) unsigned DEFAULT NULL,
  `id_category_default` int(10) unsigned DEFAULT NULL,
  `id_shop_default` int(10) unsigned NOT NULL DEFAULT 1,
  `id_tax_rules_group` int(11) unsigned NOT NULL,
  `on_sale` tinyint(1) unsigned NOT NULL DEFAULT 0,
  `online_only` tinyint(1) unsigned NOT NULL DEFAULT 0,
  `ean13` varchar(13) DEFAULT NULL,
  `isbn` varchar(32) DEFAULT NULL,
  `upc` varchar(12) DEFAULT NULL,
  `mpn` varchar(40) DEFAULT NULL,
  `ecotax` decimal(17,6) NOT NULL DEFAULT 0.000000,
  `quantity` int(10) NOT NULL DEFAULT 0,
  `minimal_quantity` int(10) unsigned NOT NULL DEFAULT 1,
  `low_stock_threshold` int(10) DEFAULT NULL,
  `low_stock_alert` tinyint(1) NOT NULL DEFAULT 0,
  `price` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `wholesale_price` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `unity` varchar(255) DEFAULT NULL,
  `unit_price_ratio` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `additional_shipping_cost` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `reference` varchar(64) DEFAULT NULL,
  `supplier_reference` varchar(64) DEFAULT NULL,
  `location` varchar(255) NOT NULL DEFAULT '',
  `width` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `height` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `depth` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `weight` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `out_of_stock` int(10) unsigned NOT NULL DEFAULT 2,
  `additional_delivery_times` tinyint(1) unsigned NOT NULL DEFAULT 1,
  `quantity_discount` tinyint(1) DEFAULT 0,
  `customizable` tinyint(2) NOT NULL DEFAULT 0,
  `uploadable_files` tinyint(4) NOT NULL DEFAULT 0,
  `text_fields` tinyint(4) NOT NULL DEFAULT 0,
  `active` tinyint(1) unsigned NOT NULL DEFAULT 0,
  `redirect_type` enum('404','301-product','302-product','301-category','302-category') NOT NULL DEFAULT '404',
  `id_type_redirected` int(10) unsigned NOT NULL DEFAULT 0,
  `available_for_order` tinyint(1) NOT NULL DEFAULT 1,
  `available_date` date DEFAULT NULL,
  `show_condition` tinyint(1) NOT NULL DEFAULT 0,
  `condition` enum('new','used','refurbished') NOT NULL DEFAULT 'new',
  `show_price` tinyint(1) NOT NULL DEFAULT 1,
  `indexed` tinyint(1) NOT NULL DEFAULT 0,
  `visibility` enum('both','catalog','search','none') NOT NULL DEFAULT 'both',
  `cache_is_pack` tinyint(1) NOT NULL DEFAULT 0,
  `cache_has_attachments` tinyint(1) NOT NULL DEFAULT 0,
  `is_virtual` tinyint(1) NOT NULL DEFAULT 0,
  `cache_default_attribute` int(10) unsigned DEFAULT NULL,
  `date_add` datetime NOT NULL,
  `date_upd` datetime NOT NULL,
  `advanced_stock_management` tinyint(1) NOT NULL DEFAULT 0,
  `pack_stock_type` int(11) unsigned NOT NULL DEFAULT 3,
  `state` int(11) unsigned NOT NULL DEFAULT 1,
  `product_type` enum('standard','pack','virtual','combinations','') NOT NULL DEFAULT '',
  PRIMARY KEY (`id_product`),
  KEY `reference_idx` (`reference`),
  KEY `supplier_reference_idx` (`supplier_reference`),
  KEY `product_supplier` (`id_supplier`),
  KEY `product_manufacturer` (`id_manufacturer`,`id_product`),
  KEY `id_category_default` (`id_category_default`),
  KEY `indexed` (`indexed`),
  KEY `date_add` (`date_add`),
  KEY `state` (`state`,`date_upd`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8mb4
</code>```
```<code>CREATE TABLE `ps_category_lang` (
  `id_category` int(10) unsigned NOT NULL,
  `id_shop` int(11) unsigned NOT NULL DEFAULT 1,
  `id_lang` int(10) unsigned NOT NULL,
  `name` varchar(128) NOT NULL,
  `description` text DEFAULT NULL,
  `link_rewrite` varchar(128) NOT NULL,
  `meta_title` varchar(255) DEFAULT NULL,
  `meta_keywords` varchar(255) DEFAULT NULL,
  `meta_description` varchar(512) DEFAULT NULL,
  PRIMARY KEY (`id_category`,`id_shop`,`id_lang`),
  KEY `category_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
</code>```
```<code>ps_product_lang CREATE TABLE `ps_product_lang` (
  `id_product` int(10) unsigned NOT NULL,
  `id_shop` int(11) unsigned NOT NULL DEFAULT 1,
  `id_lang` int(10) unsigned NOT NULL,
  `description` text DEFAULT NULL,
  `description_short` text DEFAULT NULL,
  `link_rewrite` varchar(128) NOT NULL,
  `meta_description` varchar(512) DEFAULT NULL,
  `meta_keywords` varchar(255) DEFAULT NULL,
  `meta_title` varchar(128) DEFAULT NULL,
  `name` varchar(128) NOT NULL,
  `available_now` varchar(255) DEFAULT NULL,
  `available_later` varchar(255) DEFAULT NULL,
  `delivery_in_stock` varchar(255) DEFAULT NULL,
  `delivery_out_stock` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id_product`,`id_shop`,`id_lang`),
  KEY `id_lang` (`id_lang`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
</code>```

Body:
Having this field in my database "description":

Product 1

Product 2

I want to update it to this (notice categoryName of IdProduct):

Product 1

Product 2

I have this query that picks up the pattern correctly (IdProduct = this patter ([0-9]{1,5}) ) and the IdProduct correctly (second '\2') , the problem comes when making the subquery inside the concat expression since it doesn't pick up the value of IdProduct correctly ((first '\2') in subquery).
It works if I put a literal value. For example 1.
WHERE p3.id_product = 1

Here is my code:

UPDATE ps_product_lang pl
LEFT JOIN ps_product p ON (p.id_product = pl.id_product)
LEFT JOIN ps_category_lang cl2 ON (p.id_category_default = cl2.id_category)
SET pl.description = REGEXP_REPLACE(pl.description, '<a href="https://onedomain.com/(.*)-([0-9]{1,5})(?:-.*.html|.html)', CONCAT('<a href="https://newdomain.com/'
, Replace((SELECT LOWER(cl3.name) FROM ps_product p3 LEFT JOIN ps_category_lang cl3 ON (cl3.id_category = p3.id_category_default) WHERE p3.id_product = '\\2'), ' ', '-') , '/' , '\\2', '-' , Replace(LOWER(pl.name), ' ', '-') , '.html'))

I have already tried with this and it does not work for me:
WHERE p3.id_product = CAST('\\2' AS UNSIGNED)

Here I show the structure of the table in case it helps.
Product
Product table

Product_lang
Product_lang table

Category_lang
category_lang table

Here is my output for this specific case if I put a literal value for idProduct. Example idProduct = 1. It correctly returns the name of the category (categoryId = 4).

Product 1

Product 2

I can show you the query SHOW CREATE TABLE of the tables involved. They are the Prestashop tables:

ps_product  CREATE TABLE `ps_product` (
  `id_product` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_supplier` int(10) unsigned DEFAULT NULL,
  `id_manufacturer` int(10) unsigned DEFAULT NULL,
  `id_category_default` int(10) unsigned DEFAULT NULL,
  `id_shop_default` int(10) unsigned NOT NULL DEFAULT 1,
  `id_tax_rules_group` int(11) unsigned NOT NULL,
  `on_sale` tinyint(1) unsigned NOT NULL DEFAULT 0,
  `online_only` tinyint(1) unsigned NOT NULL DEFAULT 0,
  `ean13` varchar(13) DEFAULT NULL,
  `isbn` varchar(32) DEFAULT NULL,
  `upc` varchar(12) DEFAULT NULL,
  `mpn` varchar(40) DEFAULT NULL,
  `ecotax` decimal(17,6) NOT NULL DEFAULT 0.000000,
  `quantity` int(10) NOT NULL DEFAULT 0,
  `minimal_quantity` int(10) unsigned NOT NULL DEFAULT 1,
  `low_stock_threshold` int(10) DEFAULT NULL,
  `low_stock_alert` tinyint(1) NOT NULL DEFAULT 0,
  `price` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `wholesale_price` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `unity` varchar(255) DEFAULT NULL,
  `unit_price_ratio` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `additional_shipping_cost` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `reference` varchar(64) DEFAULT NULL,
  `supplier_reference` varchar(64) DEFAULT NULL,
  `location` varchar(255) NOT NULL DEFAULT '',
  `width` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `height` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `depth` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `weight` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `out_of_stock` int(10) unsigned NOT NULL DEFAULT 2,
  `additional_delivery_times` tinyint(1) unsigned NOT NULL DEFAULT 1,
  `quantity_discount` tinyint(1) DEFAULT 0,
  `customizable` tinyint(2) NOT NULL DEFAULT 0,
  `uploadable_files` tinyint(4) NOT NULL DEFAULT 0,
  `text_fields` tinyint(4) NOT NULL DEFAULT 0,
  `active` tinyint(1) unsigned NOT NULL DEFAULT 0,
  `redirect_type` enum('404','301-product','302-product','301-category','302-category') NOT NULL DEFAULT '404',
  `id_type_redirected` int(10) unsigned NOT NULL DEFAULT 0,
  `available_for_order` tinyint(1) NOT NULL DEFAULT 1,
  `available_date` date DEFAULT NULL,
  `show_condition` tinyint(1) NOT NULL DEFAULT 0,
  `condition` enum('new','used','refurbished') NOT NULL DEFAULT 'new',
  `show_price` tinyint(1) NOT NULL DEFAULT 1,
  `indexed` tinyint(1) NOT NULL DEFAULT 0,
  `visibility` enum('both','catalog','search','none') NOT NULL DEFAULT 'both',
  `cache_is_pack` tinyint(1) NOT NULL DEFAULT 0,
  `cache_has_attachments` tinyint(1) NOT NULL DEFAULT 0,
  `is_virtual` tinyint(1) NOT NULL DEFAULT 0,
  `cache_default_attribute` int(10) unsigned DEFAULT NULL,
  `date_add` datetime NOT NULL,
  `date_upd` datetime NOT NULL,
  `advanced_stock_management` tinyint(1) NOT NULL DEFAULT 0,
  `pack_stock_type` int(11) unsigned NOT NULL DEFAULT 3,
  `state` int(11) unsigned NOT NULL DEFAULT 1,
  `product_type` enum('standard','pack','virtual','combinations','') NOT NULL DEFAULT '',
  PRIMARY KEY (`id_product`),
  KEY `reference_idx` (`reference`),
  KEY `supplier_reference_idx` (`supplier_reference`),
  KEY `product_supplier` (`id_supplier`),
  KEY `product_manufacturer` (`id_manufacturer`,`id_product`),
  KEY `id_category_default` (`id_category_default`),
  KEY `indexed` (`indexed`),
  KEY `date_add` (`date_add`),
  KEY `state` (`state`,`date_upd`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8mb4

CREATE TABLE `ps_category_lang` (
  `id_category` int(10) unsigned NOT NULL,
  `id_shop` int(11) unsigned NOT NULL DEFAULT 1,
  `id_lang` int(10) unsigned NOT NULL,
  `name` varchar(128) NOT NULL,
  `description` text DEFAULT NULL,
  `link_rewrite` varchar(128) NOT NULL,
  `meta_title` varchar(255) DEFAULT NULL,
  `meta_keywords` varchar(255) DEFAULT NULL,
  `meta_description` varchar(512) DEFAULT NULL,
  PRIMARY KEY (`id_category`,`id_shop`,`id_lang`),
  KEY `category_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

ps_product_lang CREATE TABLE `ps_product_lang` (
  `id_product` int(10) unsigned NOT NULL,
  `id_shop` int(11) unsigned NOT NULL DEFAULT 1,
  `id_lang` int(10) unsigned NOT NULL,
  `description` text DEFAULT NULL,
  `description_short` text DEFAULT NULL,
  `link_rewrite` varchar(128) NOT NULL,
  `meta_description` varchar(512) DEFAULT NULL,
  `meta_keywords` varchar(255) DEFAULT NULL,
  `meta_title` varchar(128) DEFAULT NULL,
  `name` varchar(128) NOT NULL,
  `available_now` varchar(255) DEFAULT NULL,
  `available_later` varchar(255) DEFAULT NULL,
  `delivery_in_stock` varchar(255) DEFAULT NULL,
  `delivery_out_stock` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id_product`,`id_shop`,`id_lang`),
  KEY `id_lang` (`id_lang`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4


来源: stackexchange

问:
Convert colab Ipynb file to pdf with visualizations
i want to convert my colab IPYNB file to pdf.

I tried "

```<code>!jupyter nbconvert --to pdf /content/A_B.ipynb
</code>```

" but the visualization were ignored in the pdf. How can I get code, results, and visualization in one pdf?

ContentLicense: CC BY-SA 4.0

Body:
i want to convert my colab IPYNB file to pdf.

I tried "

!jupyter nbconvert --to pdf /content/A_B.ipynb

" but the visualization were ignored in the pdf. How can I get code, results, and visualization in one pdf?


问:
Service Fabric Stateful Service Replica memory spiked without any activity
One of the replicas of the below-mentioned node started taking 82 MB and spiked up to 172 MB suddenly without any activity on the service. The dump says there are objects due to service fabric.

We are using:

Microsoft Azure Service Fabric Runtime V9.1.1390.9590

Microsoft Azure Service Fabric SDK V6.1.13909590

node : Backend_1

172mb heap dump:

00007ffbe2a85ee8       19       207848 Microsoft.ServiceFabric.Replicator.LogRecord\
00007ffbe2b893e0     5893       235720 Microsoft.ServiceFabric.Replicator.TransactionStateMachine
00007ffc3f470e70     5913       236520 System.Diagnostics.Stopwatch
00007ffc40667e00     2325       260400 System.Reflection.RuntimeMethodInfo
00007ffc3ff53758     7324       292960 System.Collections.Generic.List System.Object, mscorlib
00007ffc40622978       28       293704 System.Int64
00007ffc4066c088     4223       318520 System.Int32[]
00007ffbe2bd3498     4731       378480 Microsoft.ServiceFabric.Replicator.LogManager+FlushAsync
00007ffbe2aab6d8    17365       416760 System.Threading.Tasks.TaskCompletionSource System.Boolean, mscorlib
00007ffbe2bf8250    11774       470960 Microsoft.ServiceFabric.Data.OperationData2
00007ffbe2b895b8    11786       471440 System.Collections.Generic.List Microsoft.ServiceFabric.Replicator.LockContext, Microsoft.ServiceFabric.Data.Impl
00007ffbe2ae76c0     4731       492024 Microsoft.ServiceFabric.Replicator.PhysicalLogWriter+<FlushAsync>
00007ffc41131ea8     7766       497024 System.Action System.Threading.Tasks.Task System.Boolean, mscorlib, mscorlib
00007ffbe2aab490     7766       497024 System.Func System.Threading.Tasks.Task, mscorlib,[System.Threading.Tasks.Task, mscorlib
00007ffbe2bf67f8    17363       555616 Microsoft.ServiceFabric.Replicator.SecondaryDrainManager DisplayClass30_2
00007ffbe2aab258    17366       555712 System.Collections.ObjectModel.ReadOnlyCollection System.ArraySegment System.Byte mscorlib, mscorlib
00007ffc406612c8    17413       557216 System.ComObject
00007ffbe2ae7870     7766       559152 Microsoft.ServiceFabric.Replicator.LogRecord AwaitFlushd
00007ffbe24c0b78     1649       561408 System.Collections.Generic.Dictionary Entry Newtonsoft.Json.Serialization.JsonProperty Newtonsoft.Json Newtonsoft.Json.Serialization.JsonSerializerInternalReader+PropertyPresence, Newtonsoft.Json
00007ffbe2b88ce8     5893       612872 Microsoft.ServiceFabric.Replicator.Transaction
00007ffc411a9018     7766       621280 System.Threading.Tasks.ContinuationTaskFromResultTask System.Boolean mscorlib
00007ffc40669e18     8362       667720 System.Object
00007ffbe2aab890     7766       683408 System.Threading.Tasks.ContinuationResultTaskFromTask System.Threading.Tasks.Task mscorlib
00007ffbe2b87c20    17368       694720 System.Fabric.OperationData
00007ffbe2bf92a0    10714       857120 Microsoft.ServiceFabric.Replicator.SecondaryDrainManager DisplayClass30 DrainCopyStreamAsync
00007ffbe2bf6910    17364       972384 Microsoft.ServiceFabric.Replicator.SecondaryDrainManager DisplayClass30
00007ffbe2bf7be8    11571      1018248
```

We have tried to change the Service Fabric Cluster settings but didn't see any improvement.

We would like to know why Service Fabric Stateful Service Replica memory spiked without any activity.

Body:
One of the replicas of the below-mentioned node started taking 82 MB and spiked up to 172 MB suddenly without any activity on the service. The dump says there are objects due to service fabric.

We are using:

Microsoft Azure Service Fabric Runtime V9.1.1390.9590

Microsoft Azure Service Fabric SDK V6.1.13909590

node : Backend_1

172mb heap dump:

00007ffbe2a85ee8       19       207848 Microsoft.ServiceFabric.Replicator.LogRecord\
00007ffbe2b893e0     5893       235720 Microsoft.ServiceFabric.Replicator.TransactionStateMachine
00007ffc3f470e70     5913       236520 System.Diagnostics.Stopwatch
00007ffc40667e00     2325       260400 System.Reflection.RuntimeMethodInfo
00007ffc3ff53758     7324       292960 System.Collections.Generic.List System.Object, mscorlib
00007ffc40622978       28       293704 System.Int64
00007ffc4066c088     4223       318520 System.Int32[]
00007ffbe2bd3498     4731       378480 Microsoft.ServiceFabric.Replicator.LogManager+FlushAsync
00007ffbe2aab6d8    17365       416760 System.Threading.Tasks.TaskCompletionSource System.Boolean, mscorlib
00007ffbe2bf8250    11774       470960 Microsoft.ServiceFabric.Data.OperationData2
00007ffbe2b895b8    11786       471440 System.Collections.Generic.List Microsoft.ServiceFabric.Replicator.LockContext, Microsoft.ServiceFabric.Data.Impl
00007ffbe2ae76c0     4731       492024 Microsoft.ServiceFabric.Replicator.PhysicalLogWriter+<FlushAsync>
00007ffc41131ea8     7766       497024 System.Action System.Threading.Tasks.Task System.Boolean, mscorlib, mscorlib
00007ffbe2aab490     7766       497024 System.Func System.Threading.Tasks.Task, mscorlib,[System.Threading.Tasks.Task, mscorlib
00007ffbe2bf67f8    17363       555616 Microsoft.ServiceFabric.Replicator.SecondaryDrainManager DisplayClass30_2
00007ffbe2aab258    17366       555712 System.Collections.ObjectModel.ReadOnlyCollection System.ArraySegment System.Byte mscorlib, mscorlib
00007ffc406612c8    17413       557216 System.ComObject
00007ffbe2ae7870     7766       559152 Microsoft.ServiceFabric.Replicator.LogRecord AwaitFlushd
00007ffbe24c0b78     1649       561408 System.Collections.Generic.Dictionary Entry Newtonsoft.Json.Serialization.JsonProperty Newtonsoft.Json Newtonsoft.Json.Serialization.JsonSerializerInternalReader+PropertyPresence, Newtonsoft.Json
00007ffbe2b88ce8     5893       612872 Microsoft.ServiceFabric.Replicator.Transaction
00007ffc411a9018     7766       621280 System.Threading.Tasks.ContinuationTaskFromResultTask System.Boolean mscorlib
00007ffc40669e18     8362       667720 System.Object
00007ffbe2aab890     7766       683408 System.Threading.Tasks.ContinuationResultTaskFromTask System.Threading.Tasks.Task mscorlib
00007ffbe2b87c20    17368       694720 System.Fabric.OperationData
00007ffbe2bf92a0    10714       857120 Microsoft.ServiceFabric.Replicator.SecondaryDrainManager DisplayClass30 DrainCopyStreamAsync
00007ffbe2bf6910    17364       972384 Microsoft.ServiceFabric.Replicator.SecondaryDrainManager DisplayClass30
00007ffbe2bf7be8    11571      1018248

We have tried to change the Service Fabric Cluster settings but didn't see any improvement.

We would like to know why Service Fabric Stateful Service Replica memory spiked without any activity.


问:
Cant execute a sh file via python script to linux server
Hey I have following python code:

```<code>    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    # Connect to the Linux server
    ssh.connect(hostname="name", username="root", password="password", port=22)
#if file exists it should be removed first
    ssh.exec_command("rm name")
    sftp = ssh.open_sftp()
#create file & add minecraft username to file
    f = sftp.open("name", "w")
    f.write(user)
    f.close()
#run bash file, which will whitelist user
    stdin, stdout, stderr = ssh.exec_command('./whitelist.sh')
    sftp.close()
    ssh.close()
</code>```

This code is working on my home pc, but on my windows server the code dont execute "./whitelist.sh". I dont get a error message or something like that
What is the reason for that and how can i fix it?

Body:
Hey I have following python code:

    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    # Connect to the Linux server
    ssh.connect(hostname="name", username="root", password="password", port=22)
#if file exists it should be removed first
    ssh.exec_command("rm name")
    sftp = ssh.open_sftp()
#create file & add minecraft username to file
    f = sftp.open("name", "w")
    f.write(user)
    f.close()
#run bash file, which will whitelist user
    stdin, stdout, stderr = ssh.exec_command('./whitelist.sh')
    sftp.close()
    ssh.close()

This code is working on my home pc, but on my windows server the code dont execute "./whitelist.sh". I dont get a error message or something like that
What is the reason for that and how can i fix it?


问:
React Router with Next.js 13
I am thinking about using react router v6 with a Next 13 project I was wondering what are the down sides of using this configurations? I was looking into this and saw that this would affect SEO performance but I'm not sure of the extent it would affect SEO also I am not sure of any other downsides to this. I can't seem to find a lot about this and would love to hear what the community thinks.</p>

Title: React Router with Next.js 13


问:
Signing and verifying data using pycryptodome (RSA)
I am trying to make my blockchain model using pycryptodome 3.16.0, but can't understand how to sign and verify a blockchain transaction. As far as I understand first client (f.e. John) sign transaction using his private key. The second client (f.e. Edgar) use his public key to verify transaction.
I define my class Client:

```<code>import Crypto
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from binascii import hexlify

class Client:

    def __init__(self):
        random = Crypto.Random.new().read
        self._private_key = RSA.generate(2048, random)
        self._public_key = self._private_key.publickey()
        self._signer = PKCS1_v1_5.new(self._private_key)

    @property
    def identity(self):
        return hexlify(self._public_key.exportKey(format='DER')).decode('ascii')

    @property
    def public_key(self):
        return self._public_key
</code>```

and class Transaction:

```<code>import datetime
import collections
import binascii
from Crypto.Hash import SHA256
from Crypto.Signature import PKCS1_v1_5

class Transaction:

    def __init__(self, sender, recipient, value):
        self._sender = sender
        self._recipient = recipient
        self._value = value
        self._time = datetime.datetime.now()
        self._signature = None
        self._hash = None

    def sign_transaction(self):
        private_key = self._sender._private_key
        signer = PKCS1_v1_5.new(private_key)
        h = SHA256.new()
        self._hash = h
        self._signature = signer.sign(h)

    def validate_transaction(self):
        public_key = self._recipient._public_key
        signer = PKCS1_v1_5.new(public_key)
        return signer.verify(self._hash, self._signature)
</code>```

So, when i try to sign and verify my transaction it returns False always when signers in sign_transaction and validate_transaction are not the similiar (change _recipient to _sender in validate_transaction or _sender to _recipient in sign_transaction and it returns True regardless of which key to use for signing and verification):

```<code>import client
import transaction

t0 = transaction.Transaction(John, Edgar, 100)

t0.sign_transaction()
t0.validate_transaction() # False
</code>```

I expected that verification would return True when using the following key pairs:

sender private key - recipient public key

sender private key - sender public key (sender can verify his own transaction for himself)

Also i tried to use answers from similiar question (Signing and verifying data using pycrypto (RSA)), but now public_key.sign from Crypto.PublicKey.RSA returns NotImplementedError("Use module Crypto.Signature.pkcs1_15 instead")

Body:
I am trying to make my blockchain model using pycryptodome 3.16.0, but can't understand how to sign and verify a blockchain transaction. As far as I understand first client (f.e. John) sign transaction using his private key. The second client (f.e. Edgar) use his public key to verify transaction.
I define my class Client:

import Crypto
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from binascii import hexlify

class Client:

    def __init__(self):
        random = Crypto.Random.new().read
        self._private_key = RSA.generate(2048, random)
        self._public_key = self._private_key.publickey()
        self._signer = PKCS1_v1_5.new(self._private_key)

    @property
    def identity(self):
        return hexlify(self._public_key.exportKey(format='DER')).decode('ascii')

    @property
    def public_key(self):
        return self._public_key

and class Transaction:

import datetime
import collections
import binascii
from Crypto.Hash import SHA256
from Crypto.Signature import PKCS1_v1_5

class Transaction:

    def __init__(self, sender, recipient, value):
        self._sender = sender
        self._recipient = recipient
        self._value = value
        self._time = datetime.datetime.now()
        self._signature = None
        self._hash = None

    def sign_transaction(self):
        private_key = self._sender._private_key
        signer = PKCS1_v1_5.new(private_key)
        h = SHA256.new()
        self._hash = h
        self._signature = signer.sign(h)

    def validate_transaction(self):
        public_key = self._recipient._public_key
        signer = PKCS1_v1_5.new(public_key)
        return signer.verify(self._hash, self._signature)

So, when i try to sign and verify my transaction it returns False always when signers in sign_transaction and validate_transaction are not the similiar (change _recipient to _sender in validate_transaction or _sender to _recipient in sign_transaction and it returns True regardless of which key to use for signing and verification):

import client
import transaction

t0 = transaction.Transaction(John, Edgar, 100)

t0.sign_transaction()
t0.validate_transaction() # False

I expected that verification would return True when using the following key pairs:

sender private key - recipient public key

sender private key - sender public key (sender can verify his own transaction for himself)

Also i tried to use answers from similiar question (Signing and verifying data using pycrypto (RSA)), but now public_key.sign from Crypto.PublicKey.RSA returns NotImplementedError("Use module Crypto.Signature.pkcs1_15 instead")


问:
Plotted mean of Series outside of Confidence Band
I have hourly observation of Electricty Prices in a DataFrame. From this data I am plotting the hourly weekly average prices by taking the average for each of every 168 hours per week, and plotting it together with the averages of the other hours. In the graph, I am also plotting Confidence Band around the mean using the commands below.

The problem is, as you can see in the graph, that for two of the series the mean is outside of the confidence band in a few spots. While it looks okay in the other series.

I have been trying to trouble-shoot this but I cant understand why this is happening.

Thank you.

```<code># Create a new column to group by in the next step
df['Hour of Week'] = ((df['date'].dt.dayofweek) * 24 + 24) - (24 - df['date'].dt.hour) + 1
# Create mean, 25th and 75th percentile based on this data
df_168h_mean = df.groupby('Hour of Week').mean()
df_168h_25 = df.groupby('Hour of Week').quantile(0.25)
df_168h_75 = df.groupby('Hour of Week').quantile(0.75)

# Graphing the data
fig, (ax1, ax2, ax3, ax4) = plt.subplots(nrows=4, ncols=1, sharex=False, figsize=(10,8))
ax1.plot(df_168h_mean.Price_REG1)
ax1.fill_between(range(168), df_168h_25.Price_REG1, df_168h_75.Price_REG1,alpha=.2)
ax1.set_title('Zone 1')
ax2.plot(df_168h_mean.Price_REG2)
ax2.fill_between(range(168), df_168h_25.Price_REG2, df_168h_75.Price_REG2,alpha=.2)
ax2.set_title('Zone 2')
ax3.plot(df_168h_mean.Price_REG3)
ax3.fill_between(range(168), df_168h_25.Price_REG3, df_168h_75.Price_REG3,alpha=.2)
ax3.set_title('Zone 3')
ax4.plot(df_168h_mean.Price_REG4)
ax4.fill_between(range(168), df_168h_25.Price_REG4, df_168h_75.Price_REG4,alpha=.2)
ax4.set_title('Zone 4')
fig.tight_layout()
plt.show()
</code>```

Body:
I have hourly observation of Electricty Prices in a DataFrame. From this data I am plotting the hourly weekly average prices by taking the average for each of every 168 hours per week, and plotting it together with the averages of the other hours. In the graph, I am also plotting Confidence Band around the mean using the commands below.

The problem is, as you can see in the graph, that for two of the series the mean is outside of the confidence band in a few spots. While it looks okay in the other series.

I have been trying to trouble-shoot this but I cant understand why this is happening.

Thank you.

# Create a new column to group by in the next step
df['Hour of Week'] = ((df['date'].dt.dayofweek) * 24 + 24) - (24 - df['date'].dt.hour) + 1
# Create mean, 25th and 75th percentile based on this data
df_168h_mean = df.groupby('Hour of Week').mean()
df_168h_25 = df.groupby('Hour of Week').quantile(0.25)
df_168h_75 = df.groupby('Hour of Week').quantile(0.75)

# Graphing the data
fig, (ax1, ax2, ax3, ax4) = plt.subplots(nrows=4, ncols=1, sharex=False, figsize=(10,8))
ax1.plot(df_168h_mean.Price_REG1)
ax1.fill_between(range(168), df_168h_25.Price_REG1, df_168h_75.Price_REG1,alpha=.2)
ax1.set_title('Zone 1')
ax2.plot(df_168h_mean.Price_REG2)
ax2.fill_between(range(168), df_168h_25.Price_REG2, df_168h_75.Price_REG2,alpha=.2)
ax2.set_title('Zone 2')
ax3.plot(df_168h_mean.Price_REG3)
ax3.fill_between(range(168), df_168h_25.Price_REG3, df_168h_75.Price_REG3,alpha=.2)
ax3.set_title('Zone 3')
ax4.plot(df_168h_mean.Price_REG4)
ax4.fill_between(range(168), df_168h_25.Price_REG4, df_168h_75.Price_REG4,alpha=.2)
ax4.set_title('Zone 4')
fig.tight_layout()
plt.show()


问:
Twilio Number responding to only ONE number
My Number getting response from api but other number write 'book' but it don't respond to it.
Why is it happening , I am unable to figure it out.

When I type 'book' in whatsapp to twilio number , I got response from my api written in python but when my friend type 'book' from whatsapp to same twilio number , he didn't getting response. I have also provided url will give response when the new message comes in. I have also deployed my code to  amazon ec2 instance.


问:
Need JPA query syntax to fetch all of an entity's list property values
I have a Spring Boot 3 / Spring Data JPA / JDK19 project in which my entity has a list of Strings:

```<code>public class Recipe {
  @Id
  private String id;
  private List<String> tags;
  ...
</code>```

My repository extends MongoRepository<Recipe, String> (a CrudRepository).
I need to return the set of all tags.

I've tried findAllTags(), findByTagsContaining(String tags) passing in "", "*", " ", "?", "%", "%%" and "%?%" and the same with findByTagsLike(String tags) with no success. I could fetch all recipes and parse over their tags lists but I thought Spring Data JPA query creation might handle it better. Yesterday I wrote a repository method as findByNameContainingIgnoreCaseOrBodyContainingIgnoreCaseOrTagsContainingIgnoreCaseOrderByNameAsc

This can't be that hard ;) Any help appreciated.

Body:
I have a Spring Boot 3 / Spring Data JPA / JDK19 project in which my entity has a list of Strings:

public class Recipe {
  @Id
  private String id;
  private List<String> tags;
  ...

My repository extends MongoRepository<Recipe, String> (a CrudRepository).
I need to return the set of all tags.

I've tried findAllTags(), findByTagsContaining(String tags) passing in "", "*", " ", "?", "%", "%%" and "%?%" and the same with findByTagsLike(String tags) with no success. I could fetch all recipes and parse over their tags lists but I thought Spring Data JPA query creation might handle it better. Yesterday I wrote a repository method as findByNameContainingIgnoreCaseOrBodyContainingIgnoreCaseOrTagsContainingIgnoreCaseOrderByNameAsc

This can't be that hard ;) Any help appreciated.


问:
Convert dvi to odt filetype
Is there a software or a linux command to convert .dvi filetype to a .odt filetype? As I understand, the .dvi file is a machine readable file format which is used to render a document.

I am using MXLinux 5.16.0.

Title: Convert dvi to odt filetype


问:
How to use a variable for import video in React?
We have to import audio in react like this example:

```<code>import audio from './audio1.mp3';
</code>```

But what can I do to use different path which I have in my object. How can I change audio1.mp3 path to audio2.mp3?

Body:
We have to import audio in react like this example:

import audio from './audio1.mp3';

But what can I do to use different path which I have in my object. How can I change audio1.mp3 path to audio2.mp3?


问:
Google colab memory
I am working on local Python for my research, and planning to use the "Colab plan" as I am facing the following memory error:

"MemoryError: Unable to allocate 3.38 TiB for an array with shape (681528, 681528) and data type float64"

My question is : how many compute units do you think I need as a total?

.…………,……….…………,……….…………,……….…………,…….…………,……….…………,…………

Title: Google colab memory


问:
Python Xlib CreateNotify - Catch new window
Why this code doesn't work? When I start new program (e.g. lxappearance) nothing happens, but if I do something in program's window, code works</p>

```<code>from Xlib.display import Display
from Xlib import X, Xatom

def get_window_list():
    return [x for x in root.get_full_property(display.intern_atom('_NET_CLIENT_LIST'), Xatom.WINDOW).value]

def handle_event(aEvent):
    if aEvent.type == X.CreateNotify:
        for window in get_window_list():
            if window not in windows:
                windows.append(window)
                window_resource = display.create_resource_object('window', window)
                window_resource.configure(width = display.screen().width_in_pixels, height = display.screen().height_in_pixels-100, x = 0, y = 100)

display = Display()
root = display.screen().root
windows = get_window_list()
root.change_attributes(event_mask = X.SubstructureNotifyMask)
while True:
    ev = display.next_event()
    handle_event(ev)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Why this code doesn't work? When I start new program (e.g. lxappearance) nothing happens, but if I do something in program's window, code works

from Xlib.display import Display
from Xlib import X, Xatom

def get_window_list():
    return [x for x in root.get_full_property(display.intern_atom('_NET_CLIENT_LIST'), Xatom.WINDOW).value]

def handle_event(aEvent):
    if aEvent.type == X.CreateNotify:
        for window in get_window_list():
            if window not in windows:
                windows.append(window)
                window_resource = display.create_resource_object('window', window)
                window_resource.configure(width = display.screen().width_in_pixels, height = display.screen().height_in_pixels-100, x = 0, y = 100)

display = Display()
root = display.screen().root
windows = get_window_list()
root.change_attributes(event_mask = X.SubstructureNotifyMask)
while True:
    ev = display.next_event()
    handle_event(ev)


问:
C# SharpDX Lock Cursor inside Window
So i am making a game.

How do i make my game still detect cursor movement even if it has reached the edge of the screen and cannot move?

This is my code

```<code>        float rotationX = 0;
        float rotationY = 0;
        float dist = 1;

        float clmp(float val, float min, float max)
        {
            if (val >= max) return max;
            if(val <= min) return min;
            return val;
        }

        Control.MouseMove += (s, e) =>
        {
            var yRotate = lastX - e.X;
            var xRotate = lastY - e.Y;
            rotationX += xRotate * moveFactor;
            rotationY -= yRotate * moveFactor;
            lastY = e.Y;
            lastX = e.X;

            rotationX = clmp(rotationX, -1.5f, 1.5f);

            float h = MathF.Cos(rotationX) * dist;
            Vector3 cameraTarget = new Vector3(MathF.Cos(rotationY) * h, MathF.Sin(rotationX) * dist, MathF.Sin(rotationY) * h);

            viewMatrix = Matrix.LookAtRH(cameraPosition, cameraPosition + cameraTarget, cameraUp);
        };
</code>```

How do i make it still rotate the camera, if the cursor is outside the Window and / or cannot move anymore (for example it has reached the Clipping corner)?

Or like unity's

```<code>Cursor.lockState = CursorLockMode.Locked;
</code>```

I have tried Clip and as soon as it reaches the corner you cant move the camera anymore.

Cheers!

(No, How to restrict cursor movement in a C# Windows form?, is NOT an answer, as it uses clip and has absolutely nothing to do with a fps mouse.)

Title: C# SharpDX Lock Cursor inside Window

Body:
So i am making a game.

How do i make my game still detect cursor movement even if it has reached the edge of the screen and cannot move?

This is my code

        float rotationX = 0;
        float rotationY = 0;
        float dist = 1;

        float clmp(float val, float min, float max)
        {
            if (val >= max) return max;
            if(val <= min) return min;
            return val;
        }

        Control.MouseMove += (s, e) =>
        {
            var yRotate = lastX - e.X;
            var xRotate = lastY - e.Y;
            rotationX += xRotate * moveFactor;
            rotationY -= yRotate * moveFactor;
            lastY = e.Y;
            lastX = e.X;

            rotationX = clmp(rotationX, -1.5f, 1.5f);

            float h = MathF.Cos(rotationX) * dist;
            Vector3 cameraTarget = new Vector3(MathF.Cos(rotationY) * h, MathF.Sin(rotationX) * dist, MathF.Sin(rotationY) * h);

            viewMatrix = Matrix.LookAtRH(cameraPosition, cameraPosition + cameraTarget, cameraUp);
        };

How do i make it still rotate the camera, if the cursor is outside the Window and / or cannot move anymore (for example it has reached the Clipping corner)?

Or like unity's

Cursor.lockState = CursorLockMode.Locked;

I have tried Clip and as soon as it reaches the corner you cant move the camera anymore.

Cheers!

(No, How to restrict cursor movement in a C# Windows form?, is NOT an answer, as it uses clip and has absolutely nothing to do with a fps mouse.)


问:
New ASP.NET Core project has random attribute added to elements
I have created a new ASP.NET Core project with Visual Studio 2022.  I've run the application and looked at the source of the home page.  Several of the elements from the _Layout page have a random attribute added.

Here's a snippet of the generated html when the application is running:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Home page - WebApplication1</title>
    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/css/site.css?v=AKvNjO3dCPPS0eSU1Ez8T2wI280i08yGycV9ndytL-c" />
    <link rel="stylesheet" href="/WebApplication1.styles.css?v=bORd7i_49MmkY_u045aCr39djituvpXrqrsQ_3TezVg" />
</head>
<body>
    <header>
        <nav b-g6ltozs93r class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
            <div b-g6ltozs93r class="container">
                <a class="navbar-brand" href="/">WebApplication1</a>
                <button b-g6ltozs93r class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <span b-g6ltozs93r class="navbar-toggler-icon"></span>
                </button>
                <div b-g6ltozs93r class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
                    <ul b-g6ltozs93r class="navbar-nav flex-grow-1">
                        <li b-g6ltozs93r class="nav-item">
                            <a class="nav-link text-dark" href="/">Home</a>
                        </li>
                        <li b-g6ltozs93r class="nav-item">
                            <a class="nav-link text-dark" href="/Privacy">Privacy</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </header>
</code>```

Notice the b-g6ltozs93r in several of the elements.  This is not in the source!

The source for the HTML above from _Layout.cshtml is as follows:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - WebApplication1</title>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
    <link rel="stylesheet" href="~/WebApplication1.styles.css" asp-append-version="true" />
</head>
<body>
    <header>
        <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
            <div class="container">
                <a class="navbar-brand" asp-area="" asp-page="/Index">WebApplication1</a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
                    <ul class="navbar-nav flex-grow-1">
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </header>
</code>```

Why is that random attribute being added!?

Thanks.

Body:
I have created a new ASP.NET Core project with Visual Studio 2022.  I've run the application and looked at the source of the home page.  Several of the elements from the _Layout page have a random attribute added.

Here's a snippet of the generated html when the application is running:

<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Home page - WebApplication1</title>
    <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/css/site.css?v=AKvNjO3dCPPS0eSU1Ez8T2wI280i08yGycV9ndytL-c" />
    <link rel="stylesheet" href="/WebApplication1.styles.css?v=bORd7i_49MmkY_u045aCr39djituvpXrqrsQ_3TezVg" />

                WebApplication1
                <button b-g6ltozs93r class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">

                </button>

                            Home

                            Privacy

Notice the b-g6ltozs93r in several of the elements.  This is not in the source!

The source for the HTML above from _Layout.cshtml is as follows:

<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - WebApplication1</title>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
    <link rel="stylesheet" href="~/WebApplication1.styles.css" asp-append-version="true" />

                WebApplication1
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">

                </button>

                            Home

                            Privacy

Why is that random attribute being added!?

Thanks.


问:
Discord JDA - embed Button reaction
i want to put a embed in a specific channel. When you click on "login", a log from that should be send into a channel like "login-log". So when you click on login, a administrator can see in a channel: the user abdscasd logged in at 6:oo or something like that.
(sorry for bad english)

I already craeted a embed and two buttons. But i dont know how to create the button interact event

How can i tell him to do that? I'm new to this.

Thank you!

```<code>package main;

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.components.buttons.Button;

public class stempelsystem extends ListenerAdapter {

    public void onMessageReceived(MessageReceivedEvent ereignis) {

        if (ereignis.getMessage().getContentStripped().equals("!hochfahren")) {
            if (ereignis.getMember().getPermissions().contains(Permission.ADMINISTRATOR)) {
                EmbedBuilder embed = new EmbedBuilder();
                embed.setTitle("Timestamp");
                embed.setThumbnail("https://cdn.discordapp.com/attachments/1053705072682471525/1054037899429036123/Download.png");
                embed.setColor(0x42b580);
                embed.setDescription("");
                embed.addField(":question: Warum muss ich mich ein- bzw. ausstempeln?", "Dies dient zur Zeiterfassung um die Aktivität zu überprüfen, auch für mögliche Beförderungen.", true);
                embed.addField(":question: Was passiert wenn ich mich vergesse einzuloggen?","Unter umständen kann dies eine Beförderung beeinträchtigen oder zu einer Kündigung führen.",true);

                Button button = Button.success("login", "Login");
                Button button2 = Button.danger("logout", "Melde dich hier ab!");

                ereignis.getChannel().sendMessageEmbeds(embed.build()).setActionRow(button, button2).queue();

            }

        }
    }
//???????????????????????? i dont know
    public void onButtonInteractionEvent (ButtonInteractionEvent ereignis){
        if (ereignis.getButton().getId().equals("login")){

        }
    }
}
</code>```

Title: Discord JDA - embed Button reaction

Body:
i want to put a embed in a specific channel. When you click on "login", a log from that should be send into a channel like "login-log". So when you click on login, a administrator can see in a channel: the user abdscasd logged in at 6:oo or something like that.
(sorry for bad english)

I already craeted a embed and two buttons. But i dont know how to create the button interact event

How can i tell him to do that? I'm new to this.

Thank you!

package main;

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.components.buttons.Button;

public class stempelsystem extends ListenerAdapter {

    public void onMessageReceived(MessageReceivedEvent ereignis) {

        if (ereignis.getMessage().getContentStripped().equals("!hochfahren")) {
            if (ereignis.getMember().getPermissions().contains(Permission.ADMINISTRATOR)) {
                EmbedBuilder embed = new EmbedBuilder();
                embed.setTitle("Timestamp");
                embed.setThumbnail("https://cdn.discordapp.com/attachments/1053705072682471525/1054037899429036123/Download.png");
                embed.setColor(0x42b580);
                embed.setDescription("");
                embed.addField(":question: Warum muss ich mich ein- bzw. ausstempeln?", "Dies dient zur Zeiterfassung um die Aktivität zu überprüfen, auch für mögliche Beförderungen.", true);
                embed.addField(":question: Was passiert wenn ich mich vergesse einzuloggen?","Unter umständen kann dies eine Beförderung beeinträchtigen oder zu einer Kündigung führen.",true);

                Button button = Button.success("login", "Login");
                Button button2 = Button.danger("logout", "Melde dich hier ab!");

                ereignis.getChannel().sendMessageEmbeds(embed.build()).setActionRow(button, button2).queue();

            }

        }
    }
//???????????????????????? i dont know
    public void onButtonInteractionEvent (ButtonInteractionEvent ereignis){
        if (ereignis.getButton().getId().equals("login")){

        }
    }
}


问:
What is this UI element called and how can I make it with PyQt?
I am using PyQt5. I am refering to the vertical bar that resizes widgets on the screen:


问:
Capture the output of setup.py build_ext on stdout
In my current project, I'm extensively using Cython. I have many separated setup.py files to  build Cython code (*.pyx) with no issues at all, (python 3.8 and gcc 8.3) with the command:

```<code>python setup.py build_ext --inplace
</code>```

Here is a straightforward example:

```<code># =============================================================
#  Imports:
# =============================================================
import os
import sys
from distutils.core import setup
import setuptools
from distutils.extension import Extension
from Cython.Build import build_ext
from Cython.Build import cythonize
import numpy
import os.path
import io
import shutil
# =============================================================
#  Modules:
# =============================================================
ext_modules = [
    Extension("cc1", ["cc1.pyx"],
        extra_compile_args=['-O3','-w','-fopenmp'],
        extra_link_args=['-fopenmp','-ffast-math','-march=native'],
        include_dirs=[numpy.get_include()],
        language='c++'),
    Extension("cc2", ["cc2.pyx"],
        extra_compile_args=['-O3','-w','-fopenmp'],
        extra_link_args=['-fopenmp','-ffast-math','-march=native'],
        include_dirs=[numpy.get_include()],
        language='c++'),
]
# =============================================================
#  Class:
# =============================================================
class BuildExt(build_ext):
    def build_extensions(self):
        if '-Wstrict-prototypes' in self.compiler.compiler_so:
            self.compiler.compiler_so.remove('-Wstrict-prototypes')
        super().build_extensions()
# =============================================================
#  Main:
# =============================================================
for e in ext_modules:
    e.cython_directives = {'embedsignature': True,'boundscheck': False,'wraparound': False,'linetrace': True, 'language_level': "3"}

setup(
    name='jackProject',
    version='0.1.0',
    author='Jack',
    ext_modules=ext_modules,
    cmdclass = {'build_ext': BuildExt},
    )
</code>```

Everything works fine, and while the script is in execution, I can check the status on my console, as instance:

```<code>running build_ext
cythoning cc1.pyx to cc1.cpp
cythoning cc2.pyx to cc2.cpp
building 'cc1' extension
creating build
creating build/temp.linux-x86_64-3.8

gcc -pthread -B /home/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/home/anaconda3/include/python3.8 -c cc1.cpp -o build/temp.linux-x86_64-3.8/cc1.o -O3 -w -fopenmp
gcc -pthread -B /home/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/home/anaconda3/include/python3.8 -c cc1.cpp -o build/temp.linux-x86_64-3.8/cc1.o -O3 -w -fopenmp
g++ -pthread -shared -B /home/anaconda3/compiler_compat -L/home/anaconda3/lib -Wl,-rpath=/home/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.8/cc1.o -o /home/Desktop/DRAFT_CODING/Python/return_many_values_with_cyt/cc1.cpython-38-x86_64-linux-gnu.so -fopenmp -ffast-math -march=native

building 'cc2' extension
gcc -pthread -B /home/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/home/anaconda3/include/python3.8 -c cc2.cpp -o build/temp.linux-x86_64-3.8/cc2.o -O3 -w -fopenmp
g++ -pthread -shared -B /home/anaconda3/compiler_compat -L/home/anaconda3/lib -Wl,-rpath=/home/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.8/cc2.o -o /home/Desktop/DRAFT_CODING/Python/return_many_values_with_cyt/cc2.cpython-38-x86_64-linux-gnu.so -fopenmp -ffast-math -march=native
</code>```

Now, that I have transferred my project into my Raspberry Pi 4, everything works fine as well, but when I start the setuptools, by launching the same command as usual on the remote terminal, for the same setup.py, this time nothing is written on the terminal, while the script is cythoninzing the source code.
Launch python with the 'verbose' option is not the best...
In this case my virtualenv is based on Python 3.9. with gcc 10.21.
Can anyone tell me what is happening or which is the culprit?
How can I capture again the classic output messages I have always seen until today?
It is not the end of the world, but it was convenient to follow the status of the execution, especially when creating many shared objects at the same time.

Body:
In my current project, I'm extensively using Cython. I have many separated setup.py files to  build Cython code (*.pyx) with no issues at all, (python 3.8 and gcc 8.3) with the command:

python setup.py build_ext --inplace

Here is a straightforward example:

# =============================================================
#  Imports:
# =============================================================
import os
import sys
from distutils.core import setup
import setuptools
from distutils.extension import Extension
from Cython.Build import build_ext
from Cython.Build import cythonize
import numpy
import os.path
import io
import shutil
# =============================================================
#  Modules:
# =============================================================
ext_modules = [
    Extension("cc1", ["cc1.pyx"],
        extra_compile_args=['-O3','-w','-fopenmp'],
        extra_link_args=['-fopenmp','-ffast-math','-march=native'],
        include_dirs=[numpy.get_include()],
        language='c++'),
    Extension("cc2", ["cc2.pyx"],
        extra_compile_args=['-O3','-w','-fopenmp'],
        extra_link_args=['-fopenmp','-ffast-math','-march=native'],
        include_dirs=[numpy.get_include()],
        language='c++'),
]
# =============================================================
#  Class:
# =============================================================
class BuildExt(build_ext):
    def build_extensions(self):
        if '-Wstrict-prototypes' in self.compiler.compiler_so:
            self.compiler.compiler_so.remove('-Wstrict-prototypes')
        super().build_extensions()
# =============================================================
#  Main:
# =============================================================
for e in ext_modules:
    e.cython_directives = {'embedsignature': True,'boundscheck': False,'wraparound': False,'linetrace': True, 'language_level': "3"}

setup(
    name='jackProject',
    version='0.1.0',
    author='Jack',
    ext_modules=ext_modules,
    cmdclass = {'build_ext': BuildExt},
    )

Everything works fine, and while the script is in execution, I can check the status on my console, as instance:

running build_ext
cythoning cc1.pyx to cc1.cpp
cythoning cc2.pyx to cc2.cpp
building 'cc1' extension
creating build
creating build/temp.linux-x86_64-3.8

gcc -pthread -B /home/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/home/anaconda3/include/python3.8 -c cc1.cpp -o build/temp.linux-x86_64-3.8/cc1.o -O3 -w -fopenmp
gcc -pthread -B /home/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/home/anaconda3/include/python3.8 -c cc1.cpp -o build/temp.linux-x86_64-3.8/cc1.o -O3 -w -fopenmp
g++ -pthread -shared -B /home/anaconda3/compiler_compat -L/home/anaconda3/lib -Wl,-rpath=/home/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.8/cc1.o -o /home/Desktop/DRAFT_CODING/Python/return_many_values_with_cyt/cc1.cpython-38-x86_64-linux-gnu.so -fopenmp -ffast-math -march=native

building 'cc2' extension
gcc -pthread -B /home/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/home/anaconda3/include/python3.8 -c cc2.cpp -o build/temp.linux-x86_64-3.8/cc2.o -O3 -w -fopenmp
g++ -pthread -shared -B /home/anaconda3/compiler_compat -L/home/anaconda3/lib -Wl,-rpath=/home/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.8/cc2.o -o /home/Desktop/DRAFT_CODING/Python/return_many_values_with_cyt/cc2.cpython-38-x86_64-linux-gnu.so -fopenmp -ffast-math -march=native

Now, that I have transferred my project into my Raspberry Pi 4, everything works fine as well, but when I start the setuptools, by launching the same command as usual on the remote terminal, for the same setup.py, this time nothing is written on the terminal, while the script is cythoninzing the source code.
Launch python with the 'verbose' option is not the best...
In this case my virtualenv is based on Python 3.9. with gcc 10.21.
Can anyone tell me what is happening or which is the culprit?
How can I capture again the classic output messages I have always seen until today?
It is not the end of the world, but it was convenient to follow the status of the execution, especially when creating many shared objects at the same time.


问:
gTTS: converting text-to-speech / max retries exceeded with url / TLS/SSL connection has been closed
I am building a simple PDF Extractor and mp3 converter. The first part that is not posted reads in a PDF and extracts the body and saves it in a .txt.

The second part takes the .txt file and uses gTTS to convert it to mp3. I have read that there is an upper limit of 5000 characters per query and a maximum of 1000 queries per minute. I have made sure that each query does not exceed 5000 characters.

However, the SSL/TLS connection to translate.google.com keeps closing. I am not that strong with SSL and have no idea what TLS is and would gladly get some material to read up on.

```<code>def convert_to_mp3(path, output_file, language='en', speed=1.0):
    with open(path, 'r', encoding="utf-8") as f:
        text = f.read()
    sequences = split_body_into_sequences(text)
    #print(sequences)
    print(f'Converting {len(sequences)} sequences')
    for i, sequence in enumerate(sequences):
        print(f'Converting sequence {i+1} of {len(sequences)}')
        print(f'Length of sequence: {len(sequence[0])} characters')
        tts = gTTS(text=sequence[0], lang=language, tld="com")
        tts.save(output_file[:-4] + f'_{i+1}.mp3')
    return

def split_body_into_sequences(text):
    """
    Max length 5000 characters, otherwise Google TTS will not work.
    Split strings always at .,!,? or \n
    """
    sequences = []
    sequence = []
    sentence = ''
    for i, char in enumerate(text):
        sentence += char
        if sum(len(s) for s in sequence) + len(sentence) > 4500:
            sequences.append([' '.join(sequence)])
            sequence = []
        else:
            if char in ['.', '!', '?', '\n']:
                sequence.append(sentence)
                sentence = ''
    sequences.append([' '.join(sequence)])
    return sequences
</code>```

I get the following output before it breaks:

```<code>Converting 17 sequences
Converting sequence 1 of 17
Length of sequence: 4503 characters
Converting sequence 2 of 17
Length of sequence: 4542 characters
</code>```

and the first audio file is fine, length of approximately 6 min, whilst the second one is only generated until ~30 seconds. Then it breaks with the error:

```<code>Traceback (most recent call last):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLZeroReturnError: TLS/SSL connection has been closed (EOF) (_ssl.c:1131)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\requests\adapters.py", line 489, in send
    resp = conn.urlopen(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 265, in stream
    r = s.send(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\requests\adapters.py", line 563, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 102, in <module>
    mode_selection(mode=args.mode, filename=args.file_name, output_file=args.output_path, flags=args.flags, language=args.language, speed=args.speed)
  File "main.py", line 55, in mode_selection
    convert_to_mp3(path, output_file, language, speed)
  File "main.py", line 23, in convert_to_mp3
    tts.save(output_file[:-4] + f'_{i+1}.mp3')
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 329, in save
    self.write_to_fp(f)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 310, in write_to_fp
    for idx, decoded in enumerate(self.stream()):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 281, in stream
    raise gTTSError(tts=self)
gtts.tts.gTTSError: Failed to connect. Probable cause: Unknown
</code>```

If needed I can provide the text file, the requirements and the rest of the codebase. My python version is 3.8.15 and my gtts version is 2.3.0.

I hope this post does not anger any stack overflow overlords, if yes please quickly tell me what I did wrong for future questions!

Body:
I am building a simple PDF Extractor and mp3 converter. The first part that is not posted reads in a PDF and extracts the body and saves it in a .txt.

The second part takes the .txt file and uses gTTS to convert it to mp3. I have read that there is an upper limit of 5000 characters per query and a maximum of 1000 queries per minute. I have made sure that each query does not exceed 5000 characters.

However, the SSL/TLS connection to translate.google.com keeps closing. I am not that strong with SSL and have no idea what TLS is and would gladly get some material to read up on.

def convert_to_mp3(path, output_file, language='en', speed=1.0):
    with open(path, 'r', encoding="utf-8") as f:
        text = f.read()
    sequences = split_body_into_sequences(text)
    #print(sequences)
    print(f'Converting {len(sequences)} sequences')
    for i, sequence in enumerate(sequences):
        print(f'Converting sequence {i+1} of {len(sequences)}')
        print(f'Length of sequence: {len(sequence[0])} characters')
        tts = gTTS(text=sequence[0], lang=language, tld="com")
        tts.save(output_file[:-4] + f'_{i+1}.mp3')
    return

def split_body_into_sequences(text):
    """
    Max length 5000 characters, otherwise Google TTS will not work.
    Split strings always at .,!,? or \n
    """
    sequences = []
    sequence = []
    sentence = ''
    for i, char in enumerate(text):
        sentence += char
        if sum(len(s) for s in sequence) + len(sentence) > 4500:
            sequences.append([' '.join(sequence)])
            sequence = []
        else:
            if char in ['.', '!', '?', '\n']:
                sequence.append(sentence)
                sentence = ''
    sequences.append([' '.join(sequence)])
    return sequences

I get the following output before it breaks:

Converting 17 sequences
Converting sequence 1 of 17
Length of sequence: 4503 characters
Converting sequence 2 of 17
Length of sequence: 4542 characters

and the first audio file is fine, length of approximately 6 min, whilst the second one is only generated until ~30 seconds. Then it breaks with the error:

Traceback (most recent call last):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLZeroReturnError: TLS/SSL connection has been closed (EOF) (_ssl.c:1131)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\requests\adapters.py", line 489, in send
    resp = conn.urlopen(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 265, in stream
    r = s.send(
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\requests\adapters.py", line 563, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: /_/TranslateWebserverUi/data/batchexecute (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1131)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 102, in <module>
    mode_selection(mode=args.mode, filename=args.file_name, output_file=args.output_path, flags=args.flags, language=args.language, speed=args.speed)
  File "main.py", line 55, in mode_selection
    convert_to_mp3(path, output_file, language, speed)
  File "main.py", line 23, in convert_to_mp3
    tts.save(output_file[:-4] + f'_{i+1}.mp3')
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 329, in save
    self.write_to_fp(f)
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 310, in write_to_fp
    for idx, decoded in enumerate(self.stream()):
  File "C:\Users\yanni\anaconda3\envs\pdfreader\lib\site-packages\gtts\tts.py", line 281, in stream
    raise gTTSError(tts=self)
gtts.tts.gTTSError: Failed to connect. Probable cause: Unknown

If needed I can provide the text file, the requirements and the rest of the codebase. My python version is 3.8.15 and my gtts version is 2.3.0.

I hope this post does not anger any stack overflow overlords, if yes please quickly tell me what I did wrong for future questions!


问:
How to make pop-up modal make appear only once or on refresh of the site
I've made a pop-up window with SVG animated text in it, but I cannot make it show only once. When going through the menu and then switching back to HOME it appears again and I don't want that. Can you help me with this?

function togglePopup() {
    document.getElementById("popup").classList.toggle("active");
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.overlay {
    background: rgba(0,0,0,0.7);
    width: 100%;
    height: 100%;
}
.content-1 {
    display: flex;
    border-radius: 10px;
    box-shadow: 0px 0px 5px 11px rgba(0,0,0,0.75);
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 1200px;
    max-height: 250px;
    text-align: center;
    z-index: 3;
    background: #fff;
}
.close-btn {
    position: absolute;
    cursor: pointer;
    top: 0px;
    right: 0px;
    width: 30px;
    height: 30px;
    background: #000;
    color: #fff;
    font-size: 30px;
    font-weight: 600;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
}
#popup.active .content-1{
    top: 40%;
    visibility: hidden;
    opacity: 0;
    transition: all 500ms ease-in-out;

}</code>```

×

                        <svg class="svg" width="100%" height="100%" viewBox="0 0 1114.65 117.75" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" ><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#000" stroke-width="0.25mm" fill="none" style="stroke:#000;stroke-width:0.25mm;fill:none"><path d="M 50.85 7.05 L 23.1 7.05 L 23.1 2.7 L 55.8 2.7 L 55.8 80.7 A 48.821 48.821 0 0 1 54.465 92.426 A 34.806 34.806 0 0 1 46.875 107.25 A 29.156 29.156 0 0 1 25.548 117.4 A 39.092 39.092 0 0 1 23.55 117.45 L 22.05 117.45 A 32.471 32.471 0 0 1 2.704 111.02 A 42.21 42.21 0 0 1 0 108.9 L 0 102.75 Q 9.45 113.1 22.65 113.1 A 31.315 31.315 0 0 0 31.743 111.847 A 23.899 23.899 0 0 0 43.35 104.175 A 31.374 31.374 0 0 0 50.099 89.625 A 44.12 44.12 0 0 0 50.85 81.3 L 50.85 7.05 Z" id="0" vector-effect="non-scaling-stroke"/><path d="M 79.05 115.2 L 79.05 2.7 L 84 2.7 L 84 115.2 L 79.05 115.2 Z" id="1" vector-effect="non-scaling-stroke"/><path d="M 107.25 115.2 L 107.25 2.7 L 113.7 2.7 A 35.435 35.435 0 0 1 138.756 12.928 A 46.116 46.116 0 0 1 139.275 13.425 A 37.327 37.327 0 0 1 147.166 24.255 A 33.285 33.285 0 0 1 150.3 38.625 A 33.162 33.162 0 0 1 140.247 62.574 A 44.36 44.36 0 0 1 139.05 63.75 A 43.947 43.947 0 0 1 130.38 70.24 A 31.217 31.217 0 0 1 114.9 74.4 L 113.85 74.4 L 152.55 115.2 L 146.1 115.2 L 112.05 79.5 L 112.05 115.2 L 107.25 115.2 Z M 112.05 7.05 L 112.05 70.05 L 114.75 70.05 A 29.016 29.016 0 0 0 134.655 62.213 A 38.623 38.623 0 0 0 136.2 60.75 A 31.625 31.625 0 0 0 143.457 49.895 A 30.429 30.429 0 0 0 145.5 38.7 A 30.004 30.004 0 0 0 136.491 17.094 A 39.325 39.325 0 0 0 135.9 16.5 A 34.48 34.48 0 0 0 126.983 10.04 A 28.966 28.966 0 0 0 114 7.05 L 112.05 7.05 Z" id="2" vector-effect="non-scaling-stroke"/><path d="M 168.3 115.2 L 168.3 2.7 L 173.1 2.7 L 173.1 43.95 L 220.65 2.7 L 226.65 2.7 L 175.2 47.55 L 239.85 115.2 L 233.25 115.2 L 173.25 52.65 L 173.25 115.2 L 168.3 115.2 Z" id="3" vector-effect="non-scaling-stroke"/><path d="M 302.25 117.15 L 300 117.15 A 53.996 53.996 0 0 1 260.795 100.68 A 70.535 70.535 0 0 1 259.725 99.6 Q 242.7 82.05 242.7 58.575 A 55.329 55.329 0 0 1 259.415 18.463 A 70.704 70.704 0 0 1 259.95 17.925 A 56.528 56.528 0 0 1 300.597 0.754 A 67.464 67.464 0 0 1 301.35 0.75 A 56.144 56.144 0 0 1 342.064 17.32 A 68.026 68.026 0 0 1 342.6 17.85 Q 359.7 34.95 359.7 58.575 Q 359.7 82.2 342.75 99.675 A 57.558 57.558 0 0 1 323.555 113.033 A 54.814 54.814 0 0 1 302.25 117.15 Z M 354.75 58.875 A 51.975 51.975 0 0 0 339.319 21.173 A 63.513 63.513 0 0 0 339.075 20.925 A 51.217 51.217 0 0 0 301.965 5.104 A 61.446 61.446 0 0 0 301.275 5.1 A 51.442 51.442 0 0 0 263.894 20.434 A 63.131 63.131 0 0 0 263.4 20.925 A 51.836 51.836 0 0 0 247.654 58.185 A 61.75 61.75 0 0 0 247.65 58.875 A 52.095 52.095 0 0 0 263.155 96.651 A 64.096 64.096 0 0 0 263.4 96.9 A 52.589 52.589 0 0 0 284.172 110.125 A 53.258 53.258 0 0 0 301.2 112.8 A 51.228 51.228 0 0 0 338.506 97.393 A 63.49 63.49 0 0 0 339 96.9 A 52.11 52.11 0 0 0 354.749 59.22 A 61.963 61.963 0 0 0 354.75 58.875 Z" id="4" vector-effect="non-scaling-stroke"/><path d="M 469.95 2.7 L 414 117.75 L 358.05 2.7 L 363.45 2.7 L 414.45 106.95 L 465.15 2.7 L 469.95 2.7 Z" id="5" vector-effect="non-scaling-stroke"/><path d="M 515.1 70.2 L 515.1 115.2 L 510.15 115.2 L 510.15 70.2 L 475.95 2.7 L 481.35 2.7 L 513 64.95 L 544.05 2.7 L 548.55 2.7 L 515.1 70.2 Z" id="6" vector-effect="non-scaling-stroke"/><path d="M 670.35 117.15 L 668.1 117.15 A 53.996 53.996 0 0 1 628.895 100.68 A 70.535 70.535 0 0 1 627.825 99.6 Q 610.8 82.05 610.8 58.575 A 55.329 55.329 0 0 1 627.515 18.463 A 70.704 70.704 0 0 1 628.05 17.925 A 56.528 56.528 0 0 1 668.697 0.754 A 67.464 67.464 0 0 1 669.45 0.75 A 56.144 56.144 0 0 1 710.164 17.32 A 68.026 68.026 0 0 1 710.7 17.85 Q 727.8 34.95 727.8 58.575 Q 727.8 82.2 710.85 99.675 A 57.558 57.558 0 0 1 691.655 113.033 A 54.814 54.814 0 0 1 670.35 117.15 Z M 722.85 58.875 A 51.975 51.975 0 0 0 707.419 21.173 A 63.513 63.513 0 0 0 707.175 20.925 A 51.217 51.217 0 0 0 670.065 5.104 A 61.446 61.446 0 0 0 669.375 5.1 A 51.442 51.442 0 0 0 631.994 20.434 A 63.131 63.131 0 0 0 631.5 20.925 A 51.836 51.836 0 0 0 615.754 58.185 A 61.75 61.75 0 0 0 615.75 58.875 A 52.095 52.095 0 0 0 631.255 96.651 A 64.096 64.096 0 0 0 631.5 96.9 A 52.589 52.589 0 0 0 652.272 110.125 A 53.258 53.258 0 0 0 669.3 112.8 A 51.228 51.228 0 0 0 706.606 97.393 A 63.49 63.49 0 0 0 707.1 96.9 A 52.11 52.11 0 0 0 722.849 59.22 A 61.963 61.963 0 0 0 722.85 58.875 Z" id="8" vector-effect="non-scaling-stroke"/><path d="M 745.8 115.2 L 745.8 2.7 L 750.6 2.7 A 25.802 25.802 0 0 1 759.048 4.035 A 22.263 22.263 0 0 1 766.95 8.775 A 20.005 20.005 0 0 1 773.534 23.385 A 26.373 26.373 0 0 1 773.55 24.3 A 19.45 19.45 0 0 1 772.254 31.148 A 27.099 27.099 0 0 1 769.875 35.925 Q 766.954 40.634 763.228 42.738 A 13.185 13.185 0 0 1 761.25 43.65 Q 772.8 46.5 780.45 55.95 Q 788.1 65.4 788.1 79.725 A 33.283 33.283 0 0 1 777.989 103.793 A 44.085 44.085 0 0 1 777.15 104.625 Q 766.2 115.2 750.6 115.2 L 745.8 115.2 Z M 751.8 46.35 L 750.6 46.35 L 750.6 111 L 751.8 111 A 29.981 29.981 0 0 0 773.634 101.845 A 38.574 38.574 0 0 0 774.075 101.4 A 32.211 32.211 0 0 0 782.019 88.363 A 32.741 32.741 0 0 0 783.45 78.6 A 31.398 31.398 0 0 0 774.152 55.877 L 774.15 55.875 A 31.206 31.206 0 0 0 762.679 48.239 A 30.899 30.899 0 0 0 751.8 46.35 Z M 751.8 6.9 L 750.6 6.9 L 750.6 42.3 L 751.8 42.3 A 15.449 15.449 0 0 0 762.154 38.33 A 21.304 21.304 0 0 0 763.725 36.825 Q 768.9 31.35 768.9 24.225 A 16.65 16.65 0 0 0 763.958 12.16 A 20.505 20.505 0 0 0 763.8 12 Q 758.7 6.9 751.8 6.9 Z" id="9" vector-effect="non-scaling-stroke"/><path d="M 803.85 115.2 L 803.85 2.7 L 810.3 2.7 A 35.435 35.435 0 0 1 835.356 12.928 A 46.116 46.116 0 0 1 835.875 13.425 A 37.327 37.327 0 0 1 843.766 24.255 A 33.285 33.285 0 0 1 846.9 38.625 A 33.162 33.162 0 0 1 836.847 62.574 A 44.36 44.36 0 0 1 835.65 63.75 A 43.947 43.947 0 0 1 826.98 70.24 A 31.217 31.217 0 0 1 811.5 74.4 L 810.45 74.4 L 849.15 115.2 L 842.7 115.2 L 808.65 79.5 L 808.65 115.2 L 803.85 115.2 Z M 808.65 7.05 L 808.65 70.05 L 811.35 70.05 A 29.016 29.016 0 0 0 831.255 62.213 A 38.623 38.623 0 0 0 832.8 60.75 A 31.625 31.625 0 0 0 840.057 49.895 A 30.429 30.429 0 0 0 842.1 38.7 A 30.004 30.004 0 0 0 833.091 17.094 A 39.325 39.325 0 0 0 832.5 16.5 A 34.48 34.48 0 0 0 823.583 10.04 A 28.966 28.966 0 0 0 810.6 7.05 L 808.65 7.05 Z" id="10" vector-effect="non-scaling-stroke"/><path d="M 858.15 115.2 L 914.25 0 L 970.5 115.2 L 965.25 115.2 L 943.95 72.3 L 883.8 72.3 L 862.8 115.2 L 858.15 115.2 Z M 942.15 67.95 L 913.8 10.35 L 885.75 67.95 L 942.15 67.95 Z" id="11" vector-effect="non-scaling-stroke"/><path d="M 986.1 110.85 L 1035.3 110.85 L 1035.3 115.2 L 978.75 115.2 L 1028.25 7.05 L 978.75 7.05 L 978.75 2.7 L 1035.75 2.7 L 986.1 110.85 Z" id="12" vector-effect="non-scaling-stroke"/><path d="M 1081.2 70.2 L 1081.2 115.2 L 1076.25 115.2 L 1076.25 70.2 L 1042.05 2.7 L 1047.45 2.7 L 1079.1 64.95 L 1110.15 2.7 L 1114.65 2.7 L 1081.2 70.2 Z" id="13" vector-effect="non-scaling-stroke"/></g></svg>

```

Body:
I've made a pop-up window with SVG animated text in it, but I cannot make it show only once. When going through the menu and then switching back to HOME it appears again and I don't want that. Can you help me with this?

function togglePopup() {
    document.getElementById("popup").classList.toggle("active");
}

.overlay {
    background: rgba(0,0,0,0.7);
    width: 100%;
    height: 100%;
}
.content-1 {
    display: flex;
    border-radius: 10px;
    box-shadow: 0px 0px 5px 11px rgba(0,0,0,0.75);
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 1200px;
    max-height: 250px;
    text-align: center;
    z-index: 3;
    background: #fff;
}
.close-btn {
    position: absolute;
    cursor: pointer;
    top: 0px;
    right: 0px;
    width: 30px;
    height: 30px;
    background: #000;
    color: #fff;
    font-size: 30px;
    font-weight: 600;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
}
#popup.active .content-1{
    top: 40%;
    visibility: hidden;
    opacity: 0;
    transition: all 500ms ease-in-out;

}

×

                        <svg class="svg" width="100%" height="100%" viewBox="0 0 1114.65 117.75" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" ><g id="svgGroup" stroke-linecap="round" fill-rule="evenodd" font-size="9pt" stroke="#000" stroke-width="0.25mm" fill="none" style="stroke:#000;stroke-width:0.25mm;fill:none"><path d="M 50.85 7.05 L 23.1 7.05 L 23.1 2.7 L 55.8 2.7 L 55.8 80.7 A 48.821 48.821 0 0 1 54.465 92.426 A 34.806 34.806 0 0 1 46.875 107.25 A 29.156 29.156 0 0 1 25.548 117.4 A 39.092 39.092 0 0 1 23.55 117.45 L 22.05 117.45 A 32.471 32.471 0 0 1 2.704 111.02 A 42.21 42.21 0 0 1 0 108.9 L 0 102.75 Q 9.45 113.1 22.65 113.1 A 31.315 31.315 0 0 0 31.743 111.847 A 23.899 23.899 0 0 0 43.35 104.175 A 31.374 31.374 0 0 0 50.099 89.625 A 44.12 44.12 0 0 0 50.85 81.3 L 50.85 7.05 Z" id="0" vector-effect="non-scaling-stroke"/><path d="M 79.05 115.2 L 79.05 2.7 L 84 2.7 L 84 115.2 L 79.05 115.2 Z" id="1" vector-effect="non-scaling-stroke"/><path d="M 107.25 115.2 L 107.25 2.7 L 113.7 2.7 A 35.435 35.435 0 0 1 138.756 12.928 A 46.116 46.116 0 0 1 139.275 13.425 A 37.327 37.327 0 0 1 147.166 24.255 A 33.285 33.285 0 0 1 150.3 38.625 A 33.162 33.162 0 0 1 140.247 62.574 A 44.36 44.36 0 0 1 139.05 63.75 A 43.947 43.947 0 0 1 130.38 70.24 A 31.217 31.217 0 0 1 114.9 74.4 L 113.85 74.4 L 152.55 115.2 L 146.1 115.2 L 112.05 79.5 L 112.05 115.2 L 107.25 115.2 Z M 112.05 7.05 L 112.05 70.05 L 114.75 70.05 A 29.016 29.016 0 0 0 134.655 62.213 A 38.623 38.623 0 0 0 136.2 60.75 A 31.625 31.625 0 0 0 143.457 49.895 A 30.429 30.429 0 0 0 145.5 38.7 A 30.004 30.004 0 0 0 136.491 17.094 A 39.325 39.325 0 0 0 135.9 16.5 A 34.48 34.48 0 0 0 126.983 10.04 A 28.966 28.966 0 0 0 114 7.05 L 112.05 7.05 Z" id="2" vector-effect="non-scaling-stroke"/><path d="M 168.3 115.2 L 168.3 2.7 L 173.1 2.7 L 173.1 43.95 L 220.65 2.7 L 226.65 2.7 L 175.2 47.55 L 239.85 115.2 L 233.25 115.2 L 173.25 52.65 L 173.25 115.2 L 168.3 115.2 Z" id="3" vector-effect="non-scaling-stroke"/><path d="M 302.25 117.15 L 300 117.15 A 53.996 53.996 0 0 1 260.795 100.68 A 70.535 70.535 0 0 1 259.725 99.6 Q 242.7 82.05 242.7 58.575 A 55.329 55.329 0 0 1 259.415 18.463 A 70.704 70.704 0 0 1 259.95 17.925 A 56.528 56.528 0 0 1 300.597 0.754 A 67.464 67.464 0 0 1 301.35 0.75 A 56.144 56.144 0 0 1 342.064 17.32 A 68.026 68.026 0 0 1 342.6 17.85 Q 359.7 34.95 359.7 58.575 Q 359.7 82.2 342.75 99.675 A 57.558 57.558 0 0 1 323.555 113.033 A 54.814 54.814 0 0 1 302.25 117.15 Z M 354.75 58.875 A 51.975 51.975 0 0 0 339.319 21.173 A 63.513 63.513 0 0 0 339.075 20.925 A 51.217 51.217 0 0 0 301.965 5.104 A 61.446 61.446 0 0 0 301.275 5.1 A 51.442 51.442 0 0 0 263.894 20.434 A 63.131 63.131 0 0 0 263.4 20.925 A 51.836 51.836 0 0 0 247.654 58.185 A 61.75 61.75 0 0 0 247.65 58.875 A 52.095 52.095 0 0 0 263.155 96.651 A 64.096 64.096 0 0 0 263.4 96.9 A 52.589 52.589 0 0 0 284.172 110.125 A 53.258 53.258 0 0 0 301.2 112.8 A 51.228 51.228 0 0 0 338.506 97.393 A 63.49 63.49 0 0 0 339 96.9 A 52.11 52.11 0 0 0 354.749 59.22 A 61.963 61.963 0 0 0 354.75 58.875 Z" id="4" vector-effect="non-scaling-stroke"/><path d="M 469.95 2.7 L 414 117.75 L 358.05 2.7 L 363.45 2.7 L 414.45 106.95 L 465.15 2.7 L 469.95 2.7 Z" id="5" vector-effect="non-scaling-stroke"/><path d="M 515.1 70.2 L 515.1 115.2 L 510.15 115.2 L 510.15 70.2 L 475.95 2.7 L 481.35 2.7 L 513 64.95 L 544.05 2.7 L 548.55 2.7 L 515.1 70.2 Z" id="6" vector-effect="non-scaling-stroke"/><path d="M 670.35 117.15 L 668.1 117.15 A 53.996 53.996 0 0 1 628.895 100.68 A 70.535 70.535 0 0 1 627.825 99.6 Q 610.8 82.05 610.8 58.575 A 55.329 55.329 0 0 1 627.515 18.463 A 70.704 70.704 0 0 1 628.05 17.925 A 56.528 56.528 0 0 1 668.697 0.754 A 67.464 67.464 0 0 1 669.45 0.75 A 56.144 56.144 0 0 1 710.164 17.32 A 68.026 68.026 0 0 1 710.7 17.85 Q 727.8 34.95 727.8 58.575 Q 727.8 82.2 710.85 99.675 A 57.558 57.558 0 0 1 691.655 113.033 A 54.814 54.814 0 0 1 670.35 117.15 Z M 722.85 58.875 A 51.975 51.975 0 0 0 707.419 21.173 A 63.513 63.513 0 0 0 707.175 20.925 A 51.217 51.217 0 0 0 670.065 5.104 A 61.446 61.446 0 0 0 669.375 5.1 A 51.442 51.442 0 0 0 631.994 20.434 A 63.131 63.131 0 0 0 631.5 20.925 A 51.836 51.836 0 0 0 615.754 58.185 A 61.75 61.75 0 0 0 615.75 58.875 A 52.095 52.095 0 0 0 631.255 96.651 A 64.096 64.096 0 0 0 631.5 96.9 A 52.589 52.589 0 0 0 652.272 110.125 A 53.258 53.258 0 0 0 669.3 112.8 A 51.228 51.228 0 0 0 706.606 97.393 A 63.49 63.49 0 0 0 707.1 96.9 A 52.11 52.11 0 0 0 722.849 59.22 A 61.963 61.963 0 0 0 722.85 58.875 Z" id="8" vector-effect="non-scaling-stroke"/><path d="M 745.8 115.2 L 745.8 2.7 L 750.6 2.7 A 25.802 25.802 0 0 1 759.048 4.035 A 22.263 22.263 0 0 1 766.95 8.775 A 20.005 20.005 0 0 1 773.534 23.385 A 26.373 26.373 0 0 1 773.55 24.3 A 19.45 19.45 0 0 1 772.254 31.148 A 27.099 27.099 0 0 1 769.875 35.925 Q 766.954 40.634 763.228 42.738 A 13.185 13.185 0 0 1 761.25 43.65 Q 772.8 46.5 780.45 55.95 Q 788.1 65.4 788.1 79.725 A 33.283 33.283 0 0 1 777.989 103.793 A 44.085 44.085 0 0 1 777.15 104.625 Q 766.2 115.2 750.6 115.2 L 745.8 115.2 Z M 751.8 46.35 L 750.6 46.35 L 750.6 111 L 751.8 111 A 29.981 29.981 0 0 0 773.634 101.845 A 38.574 38.574 0 0 0 774.075 101.4 A 32.211 32.211 0 0 0 782.019 88.363 A 32.741 32.741 0 0 0 783.45 78.6 A 31.398 31.398 0 0 0 774.152 55.877 L 774.15 55.875 A 31.206 31.206 0 0 0 762.679 48.239 A 30.899 30.899 0 0 0 751.8 46.35 Z M 751.8 6.9 L 750.6 6.9 L 750.6 42.3 L 751.8 42.3 A 15.449 15.449 0 0 0 762.154 38.33 A 21.304 21.304 0 0 0 763.725 36.825 Q 768.9 31.35 768.9 24.225 A 16.65 16.65 0 0 0 763.958 12.16 A 20.505 20.505 0 0 0 763.8 12 Q 758.7 6.9 751.8 6.9 Z" id="9" vector-effect="non-scaling-stroke"/><path d="M 803.85 115.2 L 803.85 2.7 L 810.3 2.7 A 35.435 35.435 0 0 1 835.356 12.928 A 46.116 46.116 0 0 1 835.875 13.425 A 37.327 37.327 0 0 1 843.766 24.255 A 33.285 33.285 0 0 1 846.9 38.625 A 33.162 33.162 0 0 1 836.847 62.574 A 44.36 44.36 0 0 1 835.65 63.75 A 43.947 43.947 0 0 1 826.98 70.24 A 31.217 31.217 0 0 1 811.5 74.4 L 810.45 74.4 L 849.15 115.2 L 842.7 115.2 L 808.65 79.5 L 808.65 115.2 L 803.85 115.2 Z M 808.65 7.05 L 808.65 70.05 L 811.35 70.05 A 29.016 29.016 0 0 0 831.255 62.213 A 38.623 38.623 0 0 0 832.8 60.75 A 31.625 31.625 0 0 0 840.057 49.895 A 30.429 30.429 0 0 0 842.1 38.7 A 30.004 30.004 0 0 0 833.091 17.094 A 39.325 39.325 0 0 0 832.5 16.5 A 34.48 34.48 0 0 0 823.583 10.04 A 28.966 28.966 0 0 0 810.6 7.05 L 808.65 7.05 Z" id="10" vector-effect="non-scaling-stroke"/><path d="M 858.15 115.2 L 914.25 0 L 970.5 115.2 L 965.25 115.2 L 943.95 72.3 L 883.8 72.3 L 862.8 115.2 L 858.15 115.2 Z M 942.15 67.95 L 913.8 10.35 L 885.75 67.95 L 942.15 67.95 Z" id="11" vector-effect="non-scaling-stroke"/><path d="M 986.1 110.85 L 1035.3 110.85 L 1035.3 115.2 L 978.75 115.2 L 1028.25 7.05 L 978.75 7.05 L 978.75 2.7 L 1035.75 2.7 L 986.1 110.85 Z" id="12" vector-effect="non-scaling-stroke"/><path d="M 1081.2 70.2 L 1081.2 115.2 L 1076.25 115.2 L 1076.25 70.2 L 1042.05 2.7 L 1047.45 2.7 L 1079.1 64.95 L 1110.15 2.7 L 1114.65 2.7 L 1081.2 70.2 Z" id="13" vector-effect="non-scaling-stroke"/></g></svg>


问:
In google sheets how to get the product by selecting a tracking is?
I have 2 sheets one is like a reference for the values for the main sheet and in 2nd column applied formula but the challenge is that if a particular tracking number have multiple item it will over writes the adjacent cell formula by displaying error message. Also the sheet is to be designed such a way that least 5 people will enter value at a same time. Also who ever is entering data that particular persons email id and time should be recorder and at the end when opted for save the whole data should transfer from one sheet to other

Any ideas will be great helpfully,
As it is for my project The link for the Sheet is as follows:-

In Short:-

I need a sheet that tracks item by tracking number, same sheet 3 to 4 person will enter values and that particular persons id and time should be recorded automatically.

After all by clicking Save option all the data should transfer to other sheet.

Please help,

Thanks
Erfanse.


问:
Prevent Safari on iOS from auto scroll to an input on focus change
I have in my web app a login modal with a form of two fields. When user moves between the fields, the page auto scroll and move the modal. I’ve checked all the similar questions and have been trying all suggested solution but no one suits. Because of top navbar in the background being scrolled too (although it’s position=sticky) I’m guessing it’s and accessibility feature which I’ve wondered how to disable. Tip will help!


问:
Mocking cross account event bridge target rules
Trying to use moto library to mock AWS services. I have been successful trying to put a SQS queue as target to event bridge in the same account Account1. Not sure if moto supports cross account event bridge test cases, however, when I try to put event bus in Account2 as target to event bridge in Account1, I was getting some weird exception as below.

```<code>def send_to_targets(self, event_bus_name, event):
    event_bus_name = event_bus_name.split("/")[-1]
    if event_bus_name != self.event_bus_name.split("/")[-1]:
        return

    if not self.event_pattern.matches_event(event):
        return

    # supported targets
    # - CloudWatch Log Group
    # - EventBridge Archive
    # - SQS Queue + FIFO Queue
    for target in self.targets:
        arn = self._parse_arn(target["Arn"])

        if arn.service == "logs" and arn.resource_type == "log-group":
            self._send_to_cw_log_group(arn.resource_id, event)
        elif arn.service == "events" and not arn.resource_type:
            input_template = json.loads(target["InputTransformer"]["InputTemplate"])
            archive_arn = self._parse_arn(input_template["archive-arn"])

            self._send_to_events_archive(archive_arn.resource_id, event)
        elif arn.service == "sqs":
            group_id = target.get("SqsParameters", {}).get("MessageGroupId")
            self._send_to_sqs_queue(arn.resource_id, event, group_id)
        else:
            raise NotImplementedError(f"Expr not defined for {type(self)}")
        NotImplementedError: Expr not defined for <class 'moto.events.models.Rule'>
</code>```

Below is my test case where events_client.put_events(Entries=test_events) raises above error.

```<code>def test_put_events_event_bus_forwarding_rules(events_client, sqs_test, create_event_bus, roles):
pattern = {
    "source": ["source1"],
    "detail-type": ["test-detail-type"],
    "detail": {
        "test": [{"exists": True}],
    },
}

os.environ["MOTO_ACCOUNT_ID"] = "222222222222"

events_client.put_rule(
    Name='event_bus_2_rule',
    EventPattern=json.dumps(pattern),
    State="ENABLED",
    EventBusName='event_bus_2',
)

events_client.put_targets(
    Rule='event_bus_2_rule',
    EventBusName='event_bus_2',
    Targets=[
        {
            "Id": "sqs-dedup-fifo",
            "Arn": "arn:aws:sqs:us-east-1:222222222222:test-queue.fifo",
            "SqsParameters": {"MessageGroupId": "group-id"},
        }
    ],
)

policy = {
    "Statement": [
        {
            "Sid": "Account1",
            "Action": "events:PutEvents",
            "Principal": "123456789012",
            "StatementId": "Account1",
            "Effect": "n/a",
            "Resource": "n/a",
        }
    ]
}

events_client.put_permission(EventBusName='event_bus_2', Policy=json.dumps(policy))

del os.environ["MOTO_ACCOUNT_ID"]

events_client.put_rule(
    Name='event_bus_1_rule',
    RoleArn='arn:aws:iam::123456789012:role/Administrator',
    EventPattern=json.dumps(pattern),
    State="ENABLED",
    EventBusName='event_bus_1',
)

events_client.put_targets(
    Rule='event_bus_1_rule',
    EventBusName='event_bus_1',
    Targets=[
        {
            "Id": 'event_bus_2',
            "Arn": 'arn:aws:events:us-east-1:222222222222:event-bus/event_bus_2',
            "RoleArn": 'arn:aws:iam::123456789012:role/Administrator',
        },
    ],
)

test_events = [{
    'Source': 'source1',
    'DetailType': 'test-detail-type',
    'Detail': json.dumps({"test": "true"}),
    'EventBusName': 'event_bus_1'
}]

events_client.put_events(Entries=test_events)

os.environ["MOTO_ACCOUNT_ID"] = "222222222222"

sqs_client = MySQSClient()
queue_url = sqs_client.get_queue_url(queue_name="test-queue.fifo")

response = sqs_client.receive_message(
    queue_url=queue_url,
)

response["Messages"].should.have.length_of(1)

print(response)
del os.environ["MOTO_ACCOUNT_ID"]
</code>```

Body:
Trying to use moto library to mock AWS services. I have been successful trying to put a SQS queue as target to event bridge in the same account Account1. Not sure if moto supports cross account event bridge test cases, however, when I try to put event bus in Account2 as target to event bridge in Account1, I was getting some weird exception as below.

def send_to_targets(self, event_bus_name, event):
    event_bus_name = event_bus_name.split("/")[-1]
    if event_bus_name != self.event_bus_name.split("/")[-1]:
        return

    if not self.event_pattern.matches_event(event):
        return

    # supported targets
    # - CloudWatch Log Group
    # - EventBridge Archive
    # - SQS Queue + FIFO Queue
    for target in self.targets:
        arn = self._parse_arn(target["Arn"])

        if arn.service == "logs" and arn.resource_type == "log-group":
            self._send_to_cw_log_group(arn.resource_id, event)
        elif arn.service == "events" and not arn.resource_type:
            input_template = json.loads(target["InputTransformer"]["InputTemplate"])
            archive_arn = self._parse_arn(input_template["archive-arn"])

            self._send_to_events_archive(archive_arn.resource_id, event)
        elif arn.service == "sqs":
            group_id = target.get("SqsParameters", {}).get("MessageGroupId")
            self._send_to_sqs_queue(arn.resource_id, event, group_id)
        else:
            raise NotImplementedError(f"Expr not defined for {type(self)}")
        NotImplementedError: Expr not defined for <class 'moto.events.models.Rule'>

Below is my test case where events_client.put_events(Entries=test_events) raises above error.

def test_put_events_event_bus_forwarding_rules(events_client, sqs_test, create_event_bus, roles):
pattern = {
    "source": ["source1"],
    "detail-type": ["test-detail-type"],
    "detail": {
        "test": [{"exists": True}],
    },
}

os.environ["MOTO_ACCOUNT_ID"] = "222222222222"

events_client.put_rule(
    Name='event_bus_2_rule',
    EventPattern=json.dumps(pattern),
    State="ENABLED",
    EventBusName='event_bus_2',
)

events_client.put_targets(
    Rule='event_bus_2_rule',
    EventBusName='event_bus_2',
    Targets=[
        {
            "Id": "sqs-dedup-fifo",
            "Arn": "arn:aws:sqs:us-east-1:222222222222:test-queue.fifo",
            "SqsParameters": {"MessageGroupId": "group-id"},
        }
    ],
)

policy = {
    "Statement": [
        {
            "Sid": "Account1",
            "Action": "events:PutEvents",
            "Principal": "123456789012",
            "StatementId": "Account1",
            "Effect": "n/a",
            "Resource": "n/a",
        }
    ]
}

events_client.put_permission(EventBusName='event_bus_2', Policy=json.dumps(policy))

del os.environ["MOTO_ACCOUNT_ID"]

events_client.put_rule(
    Name='event_bus_1_rule',
    RoleArn='arn:aws:iam::123456789012:role/Administrator',
    EventPattern=json.dumps(pattern),
    State="ENABLED",
    EventBusName='event_bus_1',
)

events_client.put_targets(
    Rule='event_bus_1_rule',
    EventBusName='event_bus_1',
    Targets=[
        {
            "Id": 'event_bus_2',
            "Arn": 'arn:aws:events:us-east-1:222222222222:event-bus/event_bus_2',
            "RoleArn": 'arn:aws:iam::123456789012:role/Administrator',
        },
    ],
)

test_events = [{
    'Source': 'source1',
    'DetailType': 'test-detail-type',
    'Detail': json.dumps({"test": "true"}),
    'EventBusName': 'event_bus_1'
}]

events_client.put_events(Entries=test_events)

os.environ["MOTO_ACCOUNT_ID"] = "222222222222"

sqs_client = MySQSClient()
queue_url = sqs_client.get_queue_url(queue_name="test-queue.fifo")

response = sqs_client.receive_message(
    queue_url=queue_url,
)

response["Messages"].should.have.length_of(1)

print(response)
del os.environ["MOTO_ACCOUNT_ID"]