TypeError: ‘Meeting’ object is not subscriptable

Al ejecutar el siguiente código me sale TypeError: ‘Meeting’ object is not subscriptable

from datetime import datetime  class Meeting:     def __init__(self, start_time, end_time):         self.start_time = start_time         self.end_time = end_time   def check_availability(meeting, proposed_time):     result_1, result_2, result_3 = False, False, False     while True:         if proposed_time < meeting[0][0] or proposed_time > meeting[0][1]:             result_1 = True         if proposed_time < meeting[1][0] or proposed_time > meeting[1][1]:             result_2 = True         if proposed_time < meeting[2][0] or proposed_time > meeting[2][1]:             result_3 = True         if result_1 and result_2 and result_3 is True:             print(True)             break         else:             print(False)             break   meetings = [Meeting(datetime(2018, 8, 1, 9, 0, 0), datetime(2018, 8, 1, 11, 0, 0)),             Meeting(datetime(2018, 8, 1, 15, 0, 0), datetime(2018, 8, 1, 16, 0, 0)),             Meeting(datetime(2018, 8, 2, 9, 0, 0), datetime(2018, 8, 2, 10, 0, 0))]  print(check_availability(meetings, datetime(2018, 8, 1, 12, 0, 0))) print(check_availability(meetings, datetime(2018, 8, 1, 10, 0, 0))) 

How to resolve TypeError: Converting circular structure to JSON when creating SP list item?

Trying to create a list item in SharePoint using REST, getting the following error message:

Uncaught TypeError: Converting circular structure to JSON

Am I missing something obvious here?

$  .ajax({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists('" + myList + "')/items",         type: "POST",         headers: {             "accept": "application/json;odata=verbose",             "content-type": "application/json;odata=verbose",             "X-RequestDigest": $  ("#__REQUESTDIGEST").val()         },         data: JSON.stringify({             'Title': 'testing',             '__metadata': { 'type': 'SP.Data.List_x005f_TasksListItem' }         }),         success: function (data) {             TX = data.d.Id;         },         error: function (error) {             alert(JSON.stringify(error));         }     }); 

Uncaught TypeError: visitorIDs.push is not a function

I’m trying to build an array of the ID’s of the users in a peoplePicker Field by using push. So far.. I’m not having much luck as I’m getting this error “Uncaught TypeError: visitorIDs.push is not a function”

My code is below. I appreciate any suggestions/pointers:

 // Get information about all users.             var users = peoplePickerVisitors.GetAllUserInfo();             var userInfo = '';             for (var i = 0; i < users.length; i++) {                 var user = users[i];                 for (var userProperty in user) {                     userInfo += userProperty + ':  ' + user[userProperty] + '<br>';                 }             }              var userloginbase = users[0].Key;             var userlogin = userloginbase.split("\");              var context = SP.ClientContext.get_current();             var newUser = context.get_web().ensureUser('xxxxxxx\' + userlogin[1]);             context.load(newUser);             context.executeQueryAsync(function () {                 },                  function (sender, args) {                 });                 // pause for a second to let the async ensure user complete.                 setTimeout(function() {                      getAssignedToUserIdByEmail(users[0].EntityData.Email);                       visitorIDs = ResolvedToUser.Id;                     visitorIDs.push(ResolvedToUser.Id);                  }, 100);          };   

getting TypeError: allGroups.getByName is not a function

I am using this code example to redirect a user based on group, but I am facing this error message:

TypeError: allGroups.getByName is not a function 

my code:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">   </script>    <script type="text/javascript" src="/_layouts/1033/init.js"></script>  <script  type="text/javascript" src="/_layouts/15/MicrosoftAjax.js">   </script>  <script  type="text/javascript" src="/_layouts/15/sp.core.js"></script> 

    function IsCurrentUserMemberOfGroup(groupName, OnComplete) {         alert('IsCurrentUserMemberOfGroup');           console.log('CheckCurrentUerGroup called');         var currentContext = new SP.ClientContext.get_current();      console.log(currentContext );         var currentWeb = currentContext.get_web();             var currentUser = currentContext.get_web().get_currentUser();           console.log(currentUser);            currentContext.load(currentUser);          var allGroups = currentWeb.get_siteGroups();         currentContext.load(allGroups);          var group = allGroups.getByName(groupName);         currentContext.load(group);          var groupUsers = group.get_users();         currentContext.load(groupUsers);          currentContext.executeQueryAsync(OnSuccess,OnFailure);          function OnSuccess(sender, args) {             var userInGroup = false;             var groupUserEnumerator = groupUsers.getEnumerator();             while (groupUserEnumerator.moveNext()) {                 var groupUser = groupUserEnumerator.get_current();                 if (groupUser.get_id() == currentUser.get_id()) {                     userInGroup = true;                     break;                 }             }               OnComplete(userInGroup);         }          function OnFailure(sender, args) {             OnComplete(false);         }     }  function CheckCurrentUerGroup()  { console.log('CheckCurrentUerGroup called') alert('CheckCurrentUerGroup called');   IsCurrentUserMemberOfGroup("Students", function (isCurrentUserInGroup) {     if(isCurrentUserInGroup)     {         //Redirect to a certain page alert('ifCurrentUserinGroup');         window.location = "https://www.youtube.com";     }   });  }   function testExecFunc() { alert('testFunc'); }    SP.SOD.executeFunc('sp.js', 'SP.ClientContext',  CheckCurrentUerGroup());  </script> 

How can I resolve this? Have been looking around for a while but not been successful. If i need to provide more info, please note

Error “TypeError: Serial() takes no arguments” en Python (pySerial, Raspbian)

estoy intentando leer los bytes que entran mediante un usb (el cable que está enchufado en el usb es un conversor usb-serial232).

Yo no se mucho de python,y he estado buscando ayuda por internet hasta que me he encontrado con el siguiente código:

import serial ser = serial.Serial('/dev/ttyUSB0', 9600)  while True:     data = ser.readline()     if data:         print(data) 

Cuando ví esto me dio buenas vibraciones, ya que la forma que tengo de leer el mbus es con una librería de Linux que utiliza el ttyISB0.

La 1era vez que lo ejecuté me pedía que instalase la librería ‘serial’. Como estoy trabajando con PyCharm, con hacer Ctrl-Mayus-Intro se me instalaba sola.

Una vez instalé serial, me dio el error de ‘Serial’ (S mayúscula). Total, que lo instalé también.

Pero me sigue dando el siguiente error:

/root/PycharmProjects/prueba1/venv/bin/python /root/PycharmProjects/prueba1/file1.py Traceback (most recent call last):   File "/root/PycharmProjects/prueba1/file1.py", line 2, in <module>     ser = serial.Serial('/dev/ttyUSB0', 9600) TypeError: Serial() takes no arguments  Process finished with exit code 1 

Y ya no se que hacer, he estado mirando en internet, pero no hay nada sobre ese error.

Toda ayuda será bien recibida. Un Saludo

Programmatically reindexing by product ids results in Uncaught TypeError

I’ve got a custom module for importing/creating products programmatically. After products are imported I would like to reindex only the new product ids. See code below.

private function _reindexByProductIds($ ids, $ indexers) { foreach($ indexers as $ indexer) { $ index = $ this->_indexerRegistry->get($ indexer); if(!$ index->isScheduled()) { $ index->reindexList($ ids); } } }

$ ids is an array of imported ids and $ indexers is an array of all the indexer ids. This function results in an Uncaught TypeError when trying to reindex ‘catalog_product_flat’, but when I run the indexer:reindex command I don’t get this error. See error below.

Fatal error: Uncaught TypeError: Argument 2 passed to Magento\Catalog\Model\Indexer\Product\Flat\TableBuilder::_fillTemporaryEntityTable() must be of the type array, null given, called in /Users/robertbisschop/Documents/Development/www.magento-logictrade.nl.local/vendor/magento/module-catalog/Model/Indexer/Product/Flat/TableBuilder.php on line 93 and defined in /Users/robertbisschop/Documents/Development/www.magento-logictrade.nl.local/vendor/magento/module-catalog/Model/Indexer/Product/Flat/TableBuilder.php:219 Stack trace: #0 /Users/robertbisschop/Documents/Development/www.magento-logictrade.nl.local/vendor/magento/module-catalog/Model/Indexer/Product/Flat/TableBuilder.php(93): Magento\Catalog\Model\Indexer\Product\Flat\TableBuilder->_fillTemporaryEntityTable(‘catalog_product…’, NULL, Array) #1 /Users/robertbisschop/Documents/Development/www.magento-logictrade.nl.local/vendor/magento/module-catalog/Model/Indexer/Product/Flat/AbstractAction.php(152): Magento\Catalog\Model\Indexer\Product\Flat\TableBuilder->build(‘1’, A in /Users/robertbisschop/Documents/Development/www.magento-logictrade.nl.local/vendor/magento/module-catalog/Model/Indexer/Product/Flat/TableBuilder.php on line 219

I’ve been debugging for a while, but can’t figure out how to solve it. Any help is highly appreciated.

Order beforeSave plugin throws TypeError

I’ve built a plugin that catches the order beforeSave event in order to add some extra data to the an order attribute. The problem is that when this plugin fires it causes an error:

Uncaught TypeError: Argument 1 passed to Magento\Sales\Model\OrderRepository::save() must implement interface Magento\Sales\Api\Data\OrderInterface, string given, called in /var/www/html/vendor/magento/framework/Interception/Interceptor.php on line 58 and defined in /var/www/html/vendor/magento/module-sales/Model/OrderRepository.php:156 Stack trace: #0 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Sales\Model\OrderRepository->save('sales_order', 'order', NULL, NULL, NULL, NULL, Array, NULL, NULL, Array, true, 'order', Object(Magento\Store\Model\StoreManager), Object(Magento\Sales\Model\Order\Config), Object(Magento\Catalog\Model\ProductRepository\Interceptor), Object(Magento\Catalog\Model\ResourceModel\Product\CollectionFactory), Object(Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory), Object(Magento\Catalog\Model\Product\Visibility), Object(Magento\Sales\Model\Service\InvoiceService), Object(Magento\Directory\Model\CurrencyF" 

I’ve cut down my plugin so it does absolutely nothing other than return the same object in gets at the start and I’m still getting this same issue. For example;

class OrderPlugin {  protected $  _logger; protected $  _orderApi; protected $  _orderAttributeFactory; protected $  _orderExtensionFactory;  public function __construct(\Psr\Log\LoggerInterface $  logger, Data $  helper, \MyModule\Shipstation\Model\OrderAttributeFactory $  orderAttributeFactory, OrderExtensionFactory $  orderExtensionFactory) {     $  this->_logger = $  logger;     $  this->helper = $  helper;     $  this->_orderAttributeFactory = $  orderAttributeFactory;     $  this->_orderExtensionFactory = $  orderExtensionFactory; }  public function beforeSave(\Magento\Sales\Api\OrderRepositoryInterface $  subject, \Magento\Sales\Api\Data\OrderInterface $  order){      //$  resultOrder = $  this->saveFarmisonOrderIDAttribute($  resultOrder);      return $  order;  } 

my di.xml looks like;

<type name="Magento\Sales\Api\OrderRepositoryInterface">     <plugin name="MyModule_Shipstation::orderPlugin" type="MyModule\Shipstation\Plugin\OrderPlugin" />     <plugin name="MyModule_Shipstation::deliverydatePlugin" type="MyModule\Shipstation\Plugin\DeliveryDatePlugin" /> </type> 

If I totally comment out my beforeSave method then the save works correctly as expected/

Magento2: custom validation Error “Uncaught TypeError: Cannot read property ‘call’ of undefined”

In my custom validation rules shows ‘

Uncaught TypeError: Cannot read property ‘call’ of undefined’ errors!!!…

. how can i do custom logic and proper validation ?

Here is my Code


       <input class="input-text"                type="text"                data-bind="                     textInput: email,                     hasFocus: emailFocused,                     mageInit: {'mage/trim-input':{}}"                name="username"                data-validate="{required:true,'validate-custom-key':true}"                id="customer-email" /> 


// JavaScript Document var config = {     map: {         '*': {             script: 'Vendor_Module/js/script'         },         '*': {             'Vendor_Module/js/action/login': 'Vendor_Module/js/action/login'         },         '*': {             'Magento_Checkout/template/form/element/email.html':                 'Vendor_Module/template/form/element/email.html'         }     }, mixins: {         'Magento_Ui/js/lib/validation/validator': {             'Vendor_Module/js/validator-mixin': true         }     } }; 


define([     'jquery' ], function ($  ) {     "use strict";      return function () {         $  .validator.addMethod(             'validate-custom-key',             function (value) {                 // Some custom validation stuff here                 return false;             },             $  .mage.__('Your validation error message')         );     } }); 

jquery.validate.js:556 Uncaught TypeError: Cannot read property ‘call of undefined

at $ .validator.check (jquery.validate.js:556)

at $ .validator.checkForm (jquery.validate.js:372)

at $ .validator.form (jquery.validate.js:359)

at HTMLFormElement. (jquery.validate.js:90)

at HTMLFormElement.dispatch (jquery.js:5226)

at HTMLFormElement.elemData.handle (jquery.js:4878) check @

jquery.validate.js:556 checkForm @ jquery.validate.js:372 form @

jquery.validate.js:359 (anonymous) @ jquery.validate.js:90 dispatch @


elemData.handle @ jquery.js:4878