AttributeError: 'NoneType' object has no attribute 'total_seconds' (2023)

Home Messages Hashtags

Likes

(Video) How To Fix Attribute Error: ‘NoneType’ Object Has No Attribute ‘Group’?

" ); } else { wrap = '

Attachments:

    '; count = 0; for (i = 0; i < response.length; i++) { if (response[i].Inline == false) { wrap += '
  • ' + response[i].Name + ' (' + response[i].HumanSize + ')
  • "; count++; } } wrap += '

'; if (count > 0) { $('#attachments' + id).replaceWith(wrap); } else { $('#attachments' + id).replaceWith( "

" ); } } }); } var modTimeoutId; function modOnFormChange(id, draftid, groupurl, csrf) { clearTimeout(modTimeoutId); if (modSaving == true) { modTimeoutId = setTimeout(function () { // Runs 1 second (1000 ms) after the last change modOnFormChange(id, draftid, groupurl, csrf); }, 1000); return; } modTimeoutId = setTimeout(function () { // Runs 1 second (1000 ms) after the last change modSaveDraft(id, draftid, groupurl, csrf, false); }, 1000); } var modSaving = false; // modSaveDraft saves the current form state in the draft. function modSaveDraft(id, draftid, groupurl, csrf, onLeave) { if (draftid == 0) { console.log("DraftID 0, not modSaving"); return; } console.log("DELETEDDRAFT IS:", modDeletedDraft); console.log("DESTROYEDEDITOR IS:", modDestroyedEditor); if (modDeletedDraft == true) { console.log('NOT SAVING BECAUSE OF DELETED'); return; } if (modDestroyedEditor == true) { console.log('NOT SAVING BECAUSE OF DESTROYED'); return; } modSaving = true; console.log('modSaving'); var fromval = $('#from' + id).val(); var subject = $('#subject' + id).val(); var body = $('#editor' + id).val(); var bodytype = $('#bodytype' + id).val(); var private = $('#isprivate' + id).val(); var special = '0'; if ($('#special').prop('checked') == true) { special = '1'; } var bccme = '0'; if ($('#bccme').prop('checked') == true) { bccme = '1'; } var bccall = '0'; if ($('#bccall').prop('checked') == true) { bccall = '1'; } var saveval = '1'; if (onLeave == true) { saveval = '2'; } var hashtags = $('#hashtags').val(); upload = { draftid: draftid, csrf: csrf, from: fromval, subject: subject, body: body, bodytype: bodytype, special: special, private: private, bccme: bccme, bccall: bccall, hashtags: JSON.stringify(hashtags), mid: id, save: saveval }; let opts = { url: groupurl + '/draftop', cache: false, data: upload, method: 'POST', xhrFields: { withCredentials: true }, dataType: 'json' }; if (modUnloading == false) { // if we are unloading we don't want to retry, because sometimes // that can result in a spurious error, esp on Firefox opts.retryCount = 5; opts.retryVerify = modRetryVerify; } $.ajax(opts).done(function (response) { // Do something with the request console.log('saved'); modSaving = false; }); } // called to see if we need to continue retrying function modRetryVerify() { if (modDeletedDraft == true || modDestroyedEditor == true) { return false; } return true; } // stop modSaving drafts when we do a submit var postVar = null; // Code to find and return a selected piece of HTML. function modGetSelection(id) { var flag = 0; var sel = document.getSelection(); var selText = ''; id = 'msgbody' + id; var forkfork = document.getElementById(id); if (sel.rangeCount > 0) { var range = sel.getRangeAt(0); var test = range.cloneContents(); var clonedSelection = ''; if (typeof test.getElementByID != 'undefined') { clonedSelection = range.cloneContents().getElementById(id); } if (clonedSelection) { selText = clonedSelection.innerHTML; } else { clonedSelection = range.cloneContents(); var startNode = sel.getRangeAt(0).startContainer.parentNode; //console.log(modIsChild(startNode, forkfork)); if (modIsChild(startNode, forkfork)) { var div = document.createElement('div'); div.appendChild(clonedSelection); selText = div.innerHTML; } } } return selText.toString(); } function modIsChild(child, parent) { if (child === parent) return true; var current = child; while (current) { if (current === parent) return true; current = current.parentNode; } return false; } return { InitEditor: function ( id, bodyType, draftid, groupurl, csrf, handleAttachments, noFontChanges, isReply, isWiki, body, sig, onInitFunc ) { if (typeof onInitFunc === 'undefined') { onInitFunc = null; } //document.getElementById("editor" + id).addEventListener("gio:destroy", modDestroyAllEditors); document.body.addEventListener("gio:destroy", modDestroyAllEditors); modDeletedDraft = false; modDestroyedEditor = false; modUnloading = false; $('#preview' + id).hide(); $('#addattachments' + id).hide(); $('#return' + id).hide(); $('#markdownlink' + id).hide(); if (bodyType == 'html') { if (sig != '') { $('#editor' + id).val(sig); //tinyMCE.get('editor'+id).setContent(sig); } editor.initHTMLEditor( id, draftid, groupurl, csrf, handleAttachments, noFontChanges, isReply, isWiki, body, sig, onInitFunc ); } else { if (sig != '') { $('#editor' + id).val(sig); } editor.initPlainEditor(id, bodyType, groupurl, handleAttachments, sig); } }, initHTMLEditor: function ( id, draftid, groupurl, csrf, handleAttachments, noFontChanges, isReply, isWiki, body, sig, onInitFunc ) { if (typeof onInitFunc === 'undefined') { onInitFunc = null; } // extras: print, emoticons, image, insert, media, print /* All plugins: 'advlist autolink lists link image print preview hr anchor pagebreak', 'searchreplace wordcount visualblocks visualchars code fullscreen', 'insertdatetime media nonbreaking save table contextmenu directionality', 'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc' */ modDeletedDraft = false; modDestroyedEditor = false; modUnloading = false; let attachments = ''; if (handleAttachments == 0 || handleAttachments == 3) { attachments = ' addPictures addAttachments'; } let fontchanges = ''; if (noFontChanges == false) { fontchanges = ' fontselect fontsizeselect forecolor backcolor'; } let fontawesome = ' charmap'; let forceRootBlock = false; if (isWiki == true) { attachments += ' addWikiImage addWikiLink addWikiTOC'; fontawesome = ' fontawesome'; // BORK fontawesome = ''; forceRootBlock = 'p'; } let toolbar1 = 'styleselect bold italic bullist numlist link blockquote alignleft aligncenter alignright' + attachments + ' advancedToolbar'; let toolbar2 = 'strikethrough underline hr alignjustify' + fontchanges + ' removeformat' + fontawesome + ' outdent indent undo redo preview code'; let small_toolbar1 = 'bold italic link blockquote' + attachments + ' advancedToolbar'; let small_toolbar2 = 'strikethrough underline hr alignjustify removeformat outdent indent'; let tm_fonts = 'Arial=arial,helvetica,sans-serif;' + 'Arial Black=arial black,avant garde;' + 'Comic Sans MS=comic sans ms;' + 'Courier Neue=courier_newregular,courier;' + 'Helvetica Neue=helvetica neue;' + 'Helvetica=helvetica;' + 'Impact=impactregular,chicago;' + 'Lucida Grande=lucida grande;' + 'Tahoma=tahoma,arial,helvetica,sans-serif;' + 'Times New Roman=times new roman,times;' + 'Verdana=verdana,geneva'; let plugins = [ 'SplitBlockquote', 'advlist autolink lists link image preview hr anchor', 'code fullscreen', 'nonbreaking table charmap', 'textcolor colorpicker imagetools noneditable' ]; let css = fixupURL('/bootstrap/3.3.6/css/bootstrap.min.css') + ',' + fixupURL('/bootstrap/3.3.6/css/bootstrap-theme.min.css') + ',' + fixupURL('/css/groupsio.css') + ',' + fixupURL('/css/tinymce.css') + ',' + fixupURL('/fontawesome/5.9.0/css/all.min.css'); let fontsizes = '8pt 10pt 11pt 12pt 14pt 18pt 24pt 36pt'; let codesample_languages = [ { text: 'C', value: 'c' }, { text: 'C#', value: 'csharp' }, { text: 'C++', value: 'cpp' }, { text: 'CSS', value: 'css' }, { text: 'Go', value: 'go' }, { text: 'HTML/XML', value: 'markup' }, { text: 'Java', value: 'java' }, { text: 'JavaScript', value: 'javascript' }, { text: 'PHP', value: 'php' }, { text: 'Python', value: 'python' }, { text: 'Ruby', value: 'ruby' } ]; let style_formats = [ { title: 'Paragraph', block: 'p' }, { title: 'Header 1', block: 'h1' }, { title: 'Header 2', block: 'h2' }, { title: 'Header 3', block: 'h3' }, { title: 'Header 4', block: 'h4' }, { title: 'Header 5', block: 'h5' }, { title: 'Header 6', block: 'h6' } ]; if (isReply == true) { toolbar1 = 'quoteMessage ' + toolbar1; small_toolbar1 = 'quoteMessage ' + small_toolbar1; } if (document.documentElement.clientWidth > 1000) { tinymce.init({ noneditable_noneditable_class: 'fa', extended_valid_elements: 'span[*]', branding: false, link_context_toolbar: true, default_link_target: '_blank', link_assume_external_targets: true, elementpath: false, forced_root_block: forceRootBlock, content_css: css, relative_urls: false, remove_script_host: false, menubar: false, statusbar: true, plugins: plugins, toolbar1: toolbar1, toolbar2: toolbar2, font_formats: tm_fonts, browser_spellcheck: true, contextmenu: false, selector: '#editor' + id, resize: true, fontsize_formats: fontsizes, style_formats: style_formats, setup: function (teditor) { teditor.on('Init', function (e) { // see if any text is selected toquote = modGetSelection(id); if (toquote != '') { console.log('id=' + id); editor.ShowMessageHistory(id, groupurl, 'html', toquote, sig, true); } else { if (body != "") { console.log("body setContent"); teditor.setContent(body); } else if (sig != "") { console.log("sig setContent " + sig); teditor.setContent(sig); } } if (onInitFunc != null) { onInitFunc(e); } }); teditor.on('BeforeRenderUI', function (e) { teditor.theme.panel .find('toolbar') .slice(1) .hide(); }); teditor.addButton('advancedToolbar', { tooltip: 'Show advanced toolbar', icon: 'fa fa-bars', onclick: function () { if (!this.active()) { this.active(true); teditor.theme.panel .find('toolbar') .slice(1) .show(); } else { this.active(false); teditor.theme.panel .find('toolbar') .slice(1) .hide(); } } }); teditor.addButton('addPictures', { tooltip: 'Add pictures', icon: 'fa fa-image', onclick: function () { modUploaderPrompt("pictures", id, draftid, groupurl, csrf); } }); teditor.addButton('addAttachments', { tooltip: 'Add attachments', icon: 'fa fa-paperclip', onclick: function () { modUploaderPrompt("attachments", id, draftid, groupurl, csrf); } }); if (groupurl != '') { teditor.addButton('quoteMessage', { tooltip: 'Quote post', icon: 'fa fa-comment', onclick: function () { editor.ShowMessageHistory(id, groupurl, 'html', '', sig, false); } }); } if (draftid != '' && draftid != '0' && draftid != 0) { teditor.on('NodeChange', function () { //tinymce.triggerSave(); if (tinymce.activeEditor != null) { let markupStr = tinymce.activeEditor.getContent(); $('#editor' + id).val(markupStr); modOnFormChange(id, draftid, groupurl, csrf); } }); teditor.on('keyup', function () { //tinymce.triggerSave(); let markupStr = tinymce.activeEditor.getContent(); $('#editor' + id).val(markupStr); modOnFormChange(id, draftid, groupurl, csrf); }); } if (isWiki == true) { // special wiki buttons teditor.addButton('addWikiImage', { tooltip: 'Insert image', icon: 'fa fa-image', onclick: function () { $('#ImageModal').modal({}); } }); teditor.addButton('addWikiLink', { tooltip: 'Insert link to wiki page', icon: 'fa fa-book', onclick: function () { $('#LinkModal').modal({}); } }); teditor.addButton('addWikiTOC', { tooltip: 'Insert table of contents', icon: 'fa fa-list-alt', onclick: function () { $('#TOCModal').modal({}); } }); } } }); } else { tinymce.init({ branding: false, link_context_toolbar: true, default_link_target: '_blank', link_assume_external_targets: true, elementpath: false, forced_root_block: forceRootBlock, content_css: css, relative_urls: false, remove_script_host: false, menubar: false, statusbar: true, plugins: plugins, toolbar1: small_toolbar1, toolbar2: small_toolbar2, font_formats: tm_fonts, browser_spellcheck: true, contextmenu: false, selector: '#editor' + id, resize: true, fontsize_formats: fontsizes, style_formats: style_formats, setup: function (teditor) { teditor.on('Init', function (e) { // see if any text is selected toquote = modGetSelection(id); if (toquote != '') { console.log('id=' + id); editor.ShowMessageHistory(id, groupurl, 'html', toquote, sig, true); } else { if (body != "") { console.log("body setContent"); teditor.setContent(body); } else if (sig != "") { console.log("sig setContent" + sig); teditor.setContent(sig); } } if (onInitFunc != null) { onInitFunc(e); } }); teditor.on('BeforeRenderUI', function (e) { teditor.theme.panel .find('toolbar') .slice(1) .hide(); }); teditor.addButton('advancedToolbar', { tooltip: 'Show advanced toolbar', icon: 'fa fa-bars', onclick: function () { if (!this.active()) { this.active(true); teditor.theme.panel .find('toolbar') .slice(1) .show(); } else { this.active(false); teditor.theme.panel .find('toolbar') .slice(1) .hide(); } } }); teditor.addButton('addPictures', { tooltip: 'Add pictures', icon: 'fa fa-image', onclick: function () { modUploaderPrompt("pictures", id, draftid, groupurl, csrf); } }); teditor.addButton('addAttachments', { tooltip: 'Add attachments', icon: 'fa fa-paperclip', onclick: function () { modUploaderPrompt("attachments", id, draftid, groupurl, csrf); } }); if (groupurl != '') { teditor.addButton('quoteMessage', { tooltip: 'Quote post', icon: 'fa fa-comment', onclick: function () { editor.ShowMessageHistory(id, groupurl, 'html', '', sig, false); } }); } if (draftid != '' && draftid != '0' && draftid != 0) { teditor.on('NodeChange', function () { if (tinymce.activeEditor != null) { //tinymce.triggerSave(); let markupStr = tinymce.activeEditor.getContent(); $('#editor' + id).val(markupStr); modOnFormChange(id, draftid, groupurl, csrf); } }); teditor.on('keyup', function () { //tinymce.triggerSave(); let markupStr = tinymce.activeEditor.getContent(); $('#editor' + id).val(markupStr); modOnFormChange(id, draftid, groupurl, csrf); }); } // special wiki buttons teditor.addButton('addWikiImage', { tooltip: 'Add Image', icon: 'fa fa-image', onclick: function () { $('#ImageModal').modal({}); } }); teditor.addButton('addWikiLink', { tooltip: 'Add Link', icon: 'fa fa-book', onclick: function () { $('#LinkModal').modal({}); } }); teditor.addButton('addWikiTOC', { tooltip: 'Table of Contents', icon: 'fa fa-list-alt', onclick: function () { $('#TOCModal').modal({}); } }); } }); // disable tooltips because they require double taps on mobile $('.note-editor *').tooltip('disable'); } }, initPlainEditor: function (id, bodyType, groupurl, handleAttachments, sig) { $('#addattachments').show(); if (bodyType == 'plain') { $('#bodytype' + id).val('plain'); $('#preview' + id).hide(); $('#return' + id).hide(); $('#preview' + id).hide(); $('#markdownlink' + id).hide(); } else { $('#bodytype' + id).val('markdown'); $('#markdownbuttons' + id).show(); $('#preview' + id).show(); $('#return' + id).hide(); $('#previewWindow' + id).hide(); $('#markdownlink' + id).show(); } toquote = modGetSelection(id); if (toquote != '') { editor.ShowMessageHistory(id, groupurl, 'plain', toquote, sig, true); //$('#editor' + id).val(toquote); } }, InitPostDraft: function (id, draftid, csrf, groupurl) { // save the draft when leaving the page. $(window).on('beforeunload', function () { modUnloading = true; modSaveDraft(id, draftid, groupurl, csrf, true); }); // save the draft 1 second after a change $('form input, form textarea').on('input propertychange change', function () { modOnFormChange(id, draftid, groupurl, csrf); }); modUpdateAttachments(id, draftid, csrf, groupurl); if (typeof Capacitor !== 'undefined') { modInitDeviceUploader(id, draftid, csrf, groupurl); } else { modInitWebUploader(id, draftid, csrf, groupurl); } }, // InitReplyDraft creates a new draft, assumes a hidden form input called #draftidmid, and then calls initWindow(). InitReplyDraft: function ( id, bodytype, draftid, groupurl, csrf, handleAttachments, noFontChanges, isReply, isWiki, body, sig, onInitFunc ) { console.log('in InitReplyDraft draftid=' + draftid); modDeletedDraft = false; modDestroyedEditor = false; modUnloading = false; if (draftid == 0) { // create a new draft console.log('generating new draft' + groupurl); console.log('id=' + id); upload = { mid: id, csrf: csrf, body: sig }; $.ajax({ url: fixupURL(groupurl + '/reply'), cache: false, method: 'POST', data: upload, xhrFields: { withCredentials: true }, dataType: 'json', error: function (xhr, ajaxOptions, thrownError) { if (modDeletedDraft == false && modDestroyedEditor == false) { createAlert("There was an error saving the draft. Please reload the page.", true, false) } } }).done(function (response) { console.log('reply draft created'); console.log('draftid:' + response.DraftID); draftid = response.DraftID; $('#draftid' + id).val(response.DraftID); editor.InitEditor( id, bodytype, draftid, groupurl, csrf, handleAttachments, noFontChanges, true, false, body, sig, onInitFunc ); editor.InitPostDraft(id, draftid, csrf, groupurl); console.log('id=' + id); $('#bodytype' + id).val(bodytype); $('#cancel-' + id).attr( 'onclick', 'editor.discardReplyDraft("' + id + '", "' + draftid + '","' + bodytype + '","' + csrf + '","' + groupurl + '");' ); return; }); return; } editor.InitEditor( id, bodytype, draftid, groupurl, csrf, handleAttachments, noFontChanges, true, false, body, sig, onInitFunc ); editor.InitPostDraft(id, draftid, csrf, groupurl); $('#bodytype' + id).val(bodytype); $('#cancel-' + id).attr( 'onclick', 'editor.discardReplyDraft("' + id + '", "' + draftid + '","' + bodytype + '","' + csrf + '","' + groupurl + '");' ); console.log('DONE'); }, // discardReplyDraft deletes the draft and any attachments and returns the user to the previous page. discardReplyDraft: function (id, draftid, bodytype, csrf, groupurl) { console.log('editor delete reply draft'); upload = { draftid: draftid, csrf: csrf, jsondelete: '1' }; $.ajax({ url: groupurl + '/draftop', cache: false, data: upload, method: 'POST', xhrFields: { withCredentials: true }, dataType: 'json' }).done(function (response) { // Do something with the request console.log("success delete reply draft"); $('#draftid' + id).val(''); if (bodytype == 'html') { tinymce.get('editor' + id).remove(); } $('#subject' + id).val($('#origsubject' + id).val()); $('#editor' + id).val(''); modDeletedDraft = true; modDestroyedEditor = true; }); }, PreviewMarkdown: function (id, groupurl) { let markdown = $('#editor' + id).val(); upload = { md: markdown }; $.ajax({ url: fixupURL(groupurl + '/previewmd'), cache: false, data: upload, method: 'POST', xhrFields: { withCredentials: true }, dataType: 'json' }).done(function (response) { // Do something with the request console.log(response.markdown); wrap = '

' + response.markdown + '

'; $('#editwindow' + id).hide(); $('#previewWindow' + id).replaceWith(wrap); $('#previewWindow' + id).show(); }); $('#preview' + id).hide(); $('#return' + id).show(); }, ReturnMarkdown: function (id) { $('#preview' + id).show(); $('#return' + id).hide(); $('#previewWindow' + id).hide(); $('#editwindow' + id).show(); }, // groupReplyto is groupsio.ReplyTo // toggle=0 is group // toggle=1 is sender // toggle=2 is mods TogglePrivate: function (id, groupReplyto, toggle) { console.log("in TogglePrivate"); if (groupReplyto == 2) { // Reply To Moderators if (toggle == 1) { $('#replytype' + id).val('sender'); $('#isprivate' + id).val('1'); $('#replybutton' + id).html(' Reply to Sender'); $('#replybutton' + id).removeClass('btn-success').removeClass('btn-info').addClass('btn-primary'); $('#private' + id).removeClass('btn-default').addClass('btn-primary'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 2);return false;"); $('#grouptoggle' + id).removeClass('btn-success').addClass('btn-default'); $('#grouptoggle' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 1);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val('Private: ' + subj); $('#bccme' + id).show(); } else if (toggle == 2) { $('#replytype' + id).val('mods'); $('#isprivate' + id).val(''); $('#replybutton' + id).html(' Reply to Mods'); $('#replybutton' + id).removeClass('btn-success').removeClass('btn-primary').addClass('btn-info'); $('#grouptoggle' + id).removeClass('btn-success').addClass('btn-default'); $('#grouptoggle' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 0);return false;"); $('#private' + id).removeClass('btn-primary').addClass('btn-default'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 1);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val(subj.replace('Private: ', '')); $('#bccme' + id).show(); } else { $('#replytype' + id).val('group'); $('#isprivate' + id).val(''); $('#replybutton' + id).html(' Reply to Group'); $('#replybutton' + id).removeClass('btn-primary').removeClass('btn-info').addClass('btn-success'); $('#private' + id).removeClass('btn-primary').addClass('btn-default'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 2);return false;"); $('#grouptoggle' + id).removeClass('btn-default').addClass('btn-success'); $('#grouptoggle' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 2);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val(subj.replace('Private: ', '')); $('#bccme' + id).hide(); } } else if (groupReplyto == 1) { // Reply To Sender if (toggle == 1) { $('#replytype' + id).val('sender'); $('#isprivate' + id).val('1'); $('#replybutton' + id).html(' Reply to Sender'); $('#replybutton' + id).removeClass('btn-success').addClass('btn-primary'); $('#private' + id).removeClass('btn-success').addClass('btn-default'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 0);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val('Private: ' + subj); $('#bccme' + id).show(); } else { $('#replytype' + id).val('group'); $('#isprivate' + id).val(''); $('#replybutton' + id).html(' Reply to Group'); $('#replybutton' + id).removeClass('btn-primary').addClass('btn-success'); $('#private' + id).removeClass('btn-default').addClass('btn-success'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 1);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val(subj.replace('Private: ', '')); $('#bccme' + id).hide(); } } else if (groupReplyto == 3) { // Reply To Group And Sender if (toggle == 1) { $('#replytype' + id).val('sender'); $('#isprivate' + id).val('1'); $('#replybutton' + id).html(' Reply to Sender'); $('#replybutton' + id).removeClass('btn-success').addClass('btn-primary'); $('#private' + id).removeClass('btn-default').addClass('btn-primary'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 0);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val('Private: ' + subj); $('#bccme' + id).show(); } else { $('#replytype' + id).val('group'); $('#isprivate' + id).val(''); $('#replybutton' + id).html(' Reply to Group & Sender'); $('#replybutton' + id).removeClass('btn-primary').addClass('btn-success'); $('#private' + id).removeClass('btn-primary').addClass('btn-default'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 1);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val(subj.replace('Private: ', '')); $('#bccme' + id).hide(); } } else if (groupReplyto == 5) { // Reply To Followers Only if (toggle == 1) { $('#replytype' + id).val('sender'); $('#isprivate' + id).val('1'); $('#replybutton' + id).html(' Reply to Sender'); $('#replybutton' + id).removeClass('btn-success').addClass('btn-primary'); $('#private' + id).removeClass('btn-default').addClass('btn-primary'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 0);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val('Private: ' + subj); $('#bccme' + id).show(); } else { $('#replytype' + id).val('group'); $('#isprivate' + id).val(''); $('#replybutton' + id).html(' Reply to Topic Followers Only'); $('#replybutton' + id).removeClass('btn-primary').addClass('btn-success'); $('#private' + id).removeClass('btn-primary').addClass('btn-default'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 1);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val(subj.replace('Private: ', '')); $('#bccme' + id).hide(); } } else { if (toggle == 1) { $('#replytype' + id).val('sender'); $('#isprivate' + id).val('1'); $('#replybutton' + id).html(' Reply to Sender'); $('#replybutton' + id).removeClass('btn-success').addClass('btn-primary'); $('#private' + id).removeClass('btn-default').addClass('btn-primary'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 0);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val('Private: ' + subj); $('#bccme' + id).show(); } else { $('#replytype' + id).val('group'); $('#isprivate' + id).val(''); $('#replybutton' + id).html(' Reply to Group'); $('#replybutton' + id).removeClass('btn-primary').addClass('btn-success'); $('#private' + id).removeClass('btn-primary').addClass('btn-default'); $('#private' + id).attr('onclick', "editor.TogglePrivate('" + id + "','" + groupReplyto + "', 1);return false;"); subj = $('#subject' + id).val(); $('#subject' + id).val(subj.replace('Private: ', '')); $('#bccme' + id).hide(); } } tinyMCE.get('editor' + id).focus(); }, ClearTimeout: function() { clearTimeout(modTimeoutId); }, ShowMessageHistory: function( id, groupurl, bodytype, selectedText, sig, firstTime ) { console.log('URL ' + groupurl); console.log('ID ' + id); if (bodytype == 'html' && firstTime == false) { existingmsg = tinyMCE.get('editor' + id).getContent(); } else { existingmsg = $('#editor' + id).val(); } if (selectedText == '') { upload = { preview: bodytype, id: id }; } else { upload = { preview: bodytype, id: id, text: selectedText }; if (firstTime == true) { existingmsg = sig; } } $.ajax({ url: fixupURL(groupurl + '/previewmd'), cache: false, data: upload, method: 'POST', xhrFields: { withCredentials: true }, dataType: 'json' }).done(function (response) { $('#editor' + id).val(response.reply + existingmsg); if (bodytype == 'html') { console.log('SETTING ' + response.reply + existingmsg); tinyMCE.get('editor' + id).setContent(response.reply + existingmsg); tinyMCE.get('editor' + id).selection.select(tinyMCE.get('editor' + id).getBody(), true); tinyMCE.get('editor' + id).selection.collapse(false); console.log('DONE'); } }); $('#editor' + id).focus(); } /* $('form').submit(function(e) { clearTimeout(modTimeoutId); if (postVar != null) { postVar.abort(); } console.log("SETTING DELETED TO TRUE"); console.log("EVENT:", e); modDeletedDraft = true; if ($(this).hasClass('form-submitted')) { e.preventDefault(); return; } $(this).addClass('form-submitted'); }); */ };}());

  1. insync@groups.io
  2. Topics
  3. AttributeError: 'NoneType' object has no attribute 'total_seconds'

Search

Date Date 1 - 4 of 4

  • previous page
  • next page

AttributeError: 'NoneType' object has no attribute 'total_seconds'

0d39r33zk

#8715


Good Afternoon. I am running this code printed below.

```
from ib_insync import *


ib = IB()

ib.connect('127.0.0.1', 7497, clientId=2)


stock = Stock('AAPL', 'SMART', 'USD')

bars = ib.reqHistoricalData(

stock, endDateTime='', durationStr='10 D',

barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True

)

df = util.df(bars).iloc[::-1]

df.set_index('date', inplace=True)


df.drop(columns=['volume','average','barCount'], inplace=True)

print(df)

```
It provides the desired output but before doing so It prints this error:

Exception ignored in: 'pandas._libs.tslibs.conversion._localize_tso'

Traceback (most recent call last):

File "pandas/_libs/tslibs/timezones.pyx", line 246, in pandas._libs.tslibs.timezones.get_dst_info

AttributeError: 'NoneType' object has no attribute 'total_seconds'

any help in getting in the right direction would be greatly appriciated

More

  • All Messages By This Member

0d39r33zk

#8716


So after a night of research I found that his error is caused by the time zone info in the datetime objects. I corrected it by as follows. I will refactor it later but it works for now.

```

from ib_insync import *

import pandas as pd

import datetime as dt


ib = IB()

ib.connect('127.0.0.1', 7497, clientId=2)

stock = Stock('AAPL', 'SMART', 'USD')

bars = ib.reqHistoricalData(

stock, endDateTime='', durationStr='10 D',

barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True

)

# bar = bars[0]

barset = {}

for bar in bars:

date = bar.date.replace(tzinfo=None)


barset[date] = [bar.open,bar.high,bar.low,bar.close]

# print(barset)

df = pd.DataFrame.from_dict(barset, orient='index',columns=['open','high','low','close'])


print(df)

```

More

  • All Messages By This Member

Kianti

#8717


I had the same problem withib_insync.util.df(objs,labels=None)

I suspect is due to python update to 3.9.13

I had to write my code to transform bars to dataframe

The New Features of Python 3.9

Proper Time Zone Support

TIME ZONES PRIOR TO PYTHON 3.9

By default datetime objects have no time zone information

You can add a time zone to a date using the tz attribute in date/time creation methods

More

  • All Messages By This Member

Ewald de Wit

#8722


On Sun, Jan 8, 2023 at 09:46 AM, 0d39r33zk wrote:

File "pandas/_libs/tslibs/timezones.pyx", line 246, inpandas._libs.tslibs.timezones.get_dst_infoAttributeError: 'NoneType' object has no attribute 'total_seconds'

For Python 3.9 and higher the zoneinfo package is included as standard. For older python versions a back-port of the zoneinfo package is used and it seems Pandas has some kind of issue with it. Upgrading to Python 3.9 or higher should fix the problem.

-- Ewald

More

  • All Messages By This Member
1 - 4 of 4
  • previous page
  • 1
  • next page

Previous Topic Next Topic

FAQs

How do I fix AttributeError NoneType object has no attribute text? ›

How to Fix the 'NoneType' object has no attribute: 'text' Error?
  1. Double-check the web pages that you will be scraping to get information. ...
  2. Verify that the selector or selectors you are using are correct. ...
  3. Check if the website you are trying to scrape is accessible through requests and web scraping.
Feb 20, 2022

Why do I get AttributeError NoneType object has no attribute something '? ›

When ever you get a problems that involves a message such as " 'nonetype' object has no attribute ..." it means the same thing: you have tried to call a method on something that doesn't exist. If you try to do anything with that value, you will get this error.

How can you avoid NoneType object has no attribute? ›

So what you do is show the line of code that generated the error, learn how to set a data breakpoint in your debugger, and look for the condition that caused the error. You could put a “try:/catch:” block around the line(s) in question, which allows you to print out the value of the variable in question.

How do I fix NoneType error in Python? ›

The Python TypeError: NoneType Object Is Not Iterable error can be avoided by checking if a value is None or not before iterating over it. This can help ensure that only objects that have a value are iterated over, which avoids the error.

How do I fix No attribute error in Python? ›

To resolve the AttributeError , a try-except block can be used. The lines of code that can throw the AttributeError should be placed in the try block, and the except block can catch and handle the error.

How do you remove a NoneType object in Python? ›

This is how it works:
  1. None. __ne__(None) --> False.
  2. None. __ne__(anything) --> NotImplemented.

How do I get NoneType in Python? ›

If you want NoneType back, just define NoneType = type(None) .

How do you access NoneType in Python? ›

Just do type(what_ever)==type(None) for this one instance.

How do you change NoneType to int in Python? ›

int(None) throws an exception because None can't be converted to an int. The answer to your question is it can't be done. You can substitute something, like 0, or 2771, or a pink elephant, but whatever you substitute, you still won't be able to convert None to an int.

How do you handle NoneType? ›

The TypeError: 'NoneType' object is not iterable error is raised when you try to iterate over an object whose value is equal to None. To solve this error, make sure that any values that you try to iterate over have been assigned an iterable object, like a string or a list.

How do I add to NoneType? ›

Simply do aList. append('e') and your list will get the element appended.

How do you fix an object that has no attribute? ›

If you are getting an object that has no attribute error then the reason behind it is because your indentation is goofed, and you've mixed tabs and spaces. Run the script with python -tt to verify.

What is the use of NoneType in Python? ›

The None keyword is used to define a null value, or no value at all. None is not the same as 0, False, or an empty string.

What does NoneType object has no attribute mean? ›

You are getting AttributeError: 'NoneType' object has no attribute 'something' because NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None. It means that an assignment or function call up above failed or returned an unexpected result.

How do you remove None from Python output? ›

The None is passed to the print on that last line and is printed. Alternatives: Don't print the search on the last line, just call search (with no print surrounding). Don't print from the search function.

What is a NoneType error? ›

The TypeError: Nonetype object is not subscriptable is an error that occurs when you try to subscript an object that has a none value. For example: Here I have given a none value. Traceback (recent employee list) File subscriptable.py, line 2, in <module> temp=list1[0] TypeError: 'NoneType' object is not subscriptable.

What is attribute error NoneType in Python? ›

The Python "AttributeError: 'NoneType' object has no attribute" occurs when we try to access an attribute on a None value, e.g. assignment from a function that doesn't return anything. To solve the error, correct the assignment before accessing the attribute. Here is a very simple example of how the error occurs.

How do you clear an attribute in Python? ›

The delattr() method is used to delete the named attribute from the object, with the prior permission of the object. Syntax: delattr(object, name): The function takes only two parameter: object: from which the name attribute is to be removed.

What does AttributeError mean in Python? ›

One of the error in Python mostly occurs is “AttributeError”. AttributeError can be defined as an error that is raised when an attribute reference or assignment fails.

How do you set attributes in Python? ›

Attributes of a class can also be accessed using the following built-in methods and functions :
  1. getattr() – This function is used to access the attribute of object.
  2. hasattr() – This function is used to check if an attribute exist or not.
  3. setattr() – This function is used to set an attribute.
Nov 23, 2020

How do I remove None values from a list? ›

Method 1: Naive Method

In the naive method, we iterate through the whole list and append all the filtered, non-None values into a new list, hence ready to be performed with subsequent operations.

How do you remove all None values from a list in Python? ›

You can remove all None values in a Python list in the following ways:
  1. Using filter() ;
  2. Using Generator Expression;
  3. Using List Comprehension;
  4. Using a Loop.
Nov 20, 2022

Why is there NoneType? ›

Deciphering None in Tracebacks

When NoneType appears in your traceback, it means that something you didn't expect to be None actually was None , and you tried to use it in a way that you can't use None . Almost always, it's because you're trying to call a method on it.

How do I fix Attributeerror NoneType object has no attribute shape? ›

The solution to the error revolves around setting the correct path. The first way to solve the error is to first check the value of the variable if it is 'None'. The second way is to check if the given path exists with the help of the function ' os. path.

Why is Python returning None? ›

00:19 There are basically three ways to cause a value of None to be returned from a function: if the function doesn't have a return statement at all, if you have a return statement with no return value, or you can explicitly return None .

How do you replace None value in Python? ›

Given a dictionary, replace None values in every nesting with an empty dictionary. Explanation : All None values are replaced by empty dictionaries.

How to convert None to string in Python? ›

Method #1 : Using lambda This task can be performed using the lambda function. In this we check for string for None or empty string using the or operator and replace the None values with empty string.

How to convert input string to int in Python? ›

To convert, or cast, a string to an integer in Python, you use the int() built-in function. The function takes in as a parameter the initial string you want to convert, and returns the integer equivalent of the value you passed. The general syntax looks something like this: int("str") .

How to initialize a list in Python? ›

To initialize a list in Python assign one with square brackets, initialize with the list() function, create an empty list with multiplication, or use a list comprehension. The most common way to declare a list in Python is to use square brackets.

How do I know if my value is NoneType? ›

How can you tell if a object is a NoneType? Use the is operator to check for NoneType With the is operator, use the syntax object is None to return True if object has type NoneType and False otherwise.

Why does a function return NoneType? ›

It means you have not returned anything. You must add a return statement into the function. For example: def fun(a, b):

How do you add an attribute to an object? ›

Procedure
  1. On the List tab, select the object to which you want to add an attribute.
  2. On the Attributes tab, click New Row.
  3. In the Attribute field, specify a value.
  4. Specify values in the Title field and the Description field.

Can you override attributes? ›

You can not override a attribute, only hide it.

How do you check if an object has an attribute in Python? ›

We can use hasattr() function to find if a python object obj has a certain attribute or property. hasattr(obj, 'attribute'): The convention in python is that, if the property is likely to be there, simply call it and catch it with a try/except block.

What is the use of self keyword in Python? ›

The self parameter is a reference to the current instance of the class, and is used to access variables that belongs to the class.

How do I fix NoneType object is not callable? ›

TypeError: 'NoneType' object is not callable in Python
  1. Reason 1: Using the Same Name for Function and Variable.
  2. Solution: Rename Variable or Function.
  3. Reason 2: Class Methods and Class Properties Have the Same Name.
  4. Solution: Rename the Class Method or Class Attributes.
  5. Reason 3: Calling None Variable as a Function.

How to use NoneType in Python? ›

In Python 3.0 to 3.9

It effectively exists nevertheless, it only has no built-in name: You can access NoneType by writing type(None) . If you want NoneType back, just define NoneType = type(None) .

How do I find NoneType objects? ›

The None keyword in Python is a data type and an object of the NoneType class. The None keyword is used for defining a null variable or an object in Python. We can check whether a variable is None or not by using the is identity operator in Python.

How do you define a NoneType object in Python? ›

The None keyword is used to define a null variable or an object. In Python, None keyword is an object, and it is a data type of the class NoneType . We can assign None to any variable, but you can not create other NoneType objects. Note: All variables that are assigned None point to the same object.

What causes NoneType in Python? ›

NoneType in Python is a data type that simply shows that an object has no value/has a value of None . You can assign the value of None to a variable but there are also methods that return None .

How do you check if something is None in Python? ›

To check if variable is None in Python, use is keyword. if(x is None): print("x is of the 'None' type.")

How to print NoneType in Python? ›

NoneType is used to represent the state of being undefined/unknown. Python uses the keyword None to represent this special value. When you evaluate None on a code cell of Jupyter Lab, you will not see anything printed out. To display None you have to explicitly print it out using print() .

Top Articles
Latest Posts
Article information

Author: Msgr. Benton Quitzon

Last Updated: 02/09/2023

Views: 5751

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Msgr. Benton Quitzon

Birthday: 2001-08-13

Address: 96487 Kris Cliff, Teresiafurt, WI 95201

Phone: +9418513585781

Job: Senior Designer

Hobby: Calligraphy, Rowing, Vacation, Geocaching, Web surfing, Electronics, Electronics

Introduction: My name is Msgr. Benton Quitzon, I am a comfortable, charming, thankful, happy, adventurous, handsome, precious person who loves writing and wants to share my knowledge and understanding with you.