I have recently start learning how to make xbmc/kodi addons.
I am trying to create multiple directories but keep getting "error:script failed:" when i click the addon icon on video section.
Could anyone help me fix this error and create multiple directories so i could populate them with data later? I searched a lot to find a beginner tutorial on how to make directories but couldn't find one. Thanks in advance.
import urllib, urllib2, sys, re, os, unicodedata
import xbmc, xbmcgui, xbmcplugin, xbmcaddon, base64
plugin_handle = int(sys.argv[1])
def CATEGORIES():
add_dir("search",url,1,"")
add_dir( "AnimalS",url,1,"")
add_dir( "cars",url,1,"")
add_dir("Fruits",url,1,"")
url = None
name = None
mode = None
iconimage = None
if mode==None or url==None or len(url)<1:
print ""
CATEGORIES()
xbmcplugin.endOfDirectory(plugin_handle)
error on xbmc.log:
ERROR: EXCEPTION Thrown (PythonToCppException) :
-->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.IndentationError'>
Error Contents: ('unindent does not match any outer indentation level', ('C:\\.....addons\\plugin.video.populateDirectory\\addon.py', 12, 32, ' add_dir("Fruits",url,1,"")\n'))
IndentationError: ('unindent does not match any outer indentation level', ('C:\\....\\addons\\plugin.video.populateDirectory\\addon.py', 12, 32, ' add_dir("Fruits",url,1,"")\n'))
-->End of Python script error report<--
ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://plugin.video.test/
ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.test/) failed
NOTICE: Thread BackgroundLoader start, auto delete: false
Related
I'm trying to run the following script in VS Code, however I keep getting an indentation error, which is kinda self-explanatory, but I haven't been able to find the error? Is there a way auto-formatting in VS Code?
import logging
import uuid
import json
import azure.functions as func
def main(msg: func.QueueMessage, message: func.Out[func.Document]) -> None:
logging.info('Python queue trigger function processed a queue item: %s', msg_body)
data = json.dumps({
'id': msg.id,
'body': msg.get_body().decode('utf-8'),
'expiration_time': (msg.expiration_time.isoformat()
if msg.expiration_time else None),
'insertion_time': (msg.insertion_time.isoformat()
if msg.insertion_time else None),
'time_next_visible': (msg.time_next_visible.isoformat()
if msg.time_next_visible else None),
'pop_receipt': msg.pop_receipt,
'dequeue_count': msg.dequeue_count
})
message.set(func.Document.from_json(json.dumps(data)))
My error message when I run the script:
[Running] python -u "c:\Users\artem\Desktop\function\inspariqueuestore\__init__.py"
File "c:\Users\artem\Desktop\function\inspariqueuestore\__init__.py", line 12
data = json.dumps({
^
IndentationError: unexpected indent
[Done] exited with code=1 in 0.093 seconds
UPDATE
I mixed tabs and spaces apparently. Issue resolved.
I don't see any indentation errors in your file.
Yes, you can try to format your file using VS Code.
There is a shortcut named editor.action.formatDocument.
You can find the exact keys for your setup in settings.
In my case it is shift + option (alt) + F
Edit;
My original post was too vague regarding what my problem was, so after working on my assignment for some time I've adjusted/fixed most of my code. However, I'm still having trouble getting it to work. Now when I run the script from the cmd prompt I get this message...
Traceback (most recent call last):
File "/PythonScriptsR2/autoadmin_a1_errors.py", line 45, in <module>
log_handle_three = win32evtlog.OpenEventLog(computer,log_type_three)
pywintypes.error: (1722, 'OpenEventLogW', 'The RPC server is
unavailable.')
Here is what my current code looks like
(I wrote some comments on and around line 45 so it's easier to find);
import win32evtlog
import win32evtlogutil
import win32security
import win32con
import time
import winerror
import re
import string
import sys
import traceback
####################################################################
# All error entries for the last 3 months
########
#set date format
def date2sec(self,evt_date):
'''
convert '12/23/99 15:54:09' to seconds
print '333333',evt_date
'''
regexp=re.compile('(.*)\\s(.*)')
reg_result=regexp.search(evt_date)
date = reg.result.group(1)
time = reg_result.group(2)
(mon,day,yr) = map(lambda x: sring.atoi(x),string.split(date,'/'))
(hr,min,sec) = map(lambda x: sring.atoi(x),string.split(time,':'))
tup = [yr,mon,day,hr,min,sec,0,0,0]
sec = time.mktime(tup)
return sec
################
#Initialize variables
flags_three=win32evtlog.EVENTLOG_BACKWARDS_READ|\
win32evtlog.EVENTLOG_SEQUENTIAL_READ
#Dictionary to convert event type into human readable form
evt_dict={win32con.EVENTLOG_AUDIT_FAILURE:'EVENTLOG_AUDIT_FAILURE',\
win32con.EVENTLOG_AUDIT_SUCCESS:'EVENTLOG_AUDIT_SUCCESS',\
win32con.EVENTLOG_INFORMATION_TYPE:'EVENTLOG_INFORMATION_TYPE',\
win32con.EVENTLOG_WARNING_TYPE:'EVENTLOG_WARNING_TYPE',\
win32con.EVENTLOG_ERROR_TYPE:'EVENTLOG_ERROR_TYPE'}
computer='bedrock'
log_type_three='System'
begin_sec=time.time()
begin_time=time.strftime('%H:%M:%S ',time.localtime(begin_sec))
############ \/ Line 45 \/ #############
log_handle_three=win32evtlog.OpenEventLog(computer,log_type_three) #line45
############ /\ Line 45 /\ #############
################
#Open the Event Log
print(log_type_three,' error events found from the last three months
since:',begin_time)
try:
ev_ents=1
while ev_ents:
ev_ents=win32evtlog.ReadEventLog(log_handle_three,flags_three, 0)
for ev_obj in ev_ents:
#################
#check if the event is recent enough
#checking data from the last three months
date = ev_ent.TimeGenerated.Format()
time = ev_ent.TimeGenerated.Format()
seconds = date2sec(date)
if seconds < begin_sec-7862400: break
#################
#if the data is recent enough/from the correct time frame,
#print it
source=str(ev_obj.SourceName)
message=str(win32evtlogutil.SafeFormatMessage(ev_obj,\
logtype))
record = str(ev_obj.RecordNumber)
print(string.join((record,source,date,\
time,message[0:15]),':'))
if seconds < begin_sec-7862400: break #You need to get out of
#the while loop as well
win32evtlog.CloseEventLog(log_handle_three)
except:
print(traceback.print_exc(sys.exc_info()))
So right now my questions are, what does this error message mean, why am I getting this error message, and what are some things I could do to try and fix it.
I think he may want us to use windows powershell to call the script, however, when I did this I got the same error message as I did at the cmd prompt so I'm not sure if it makes a difference.
For some reason, I think it's probably trying to access "bedrock" using the network stack instead of just grabbing it from the local machine. I would make sure that "bedrock" is the actual computer name that you get when you execute "hostname" from the CLI.
I ran into a similar issue using a computer name of "localhost" where it didn't work in certain environments with the same error. Changing that value to the actual local computer name resolved the problem for me.
I've just started experimenting with flask and
I am trying to list a network driver using it. This is the command that I type on my browser. But I get an error that it cant find the path
http://127.0.0.1:5000/130.13.5.8/D/dir/
The function works for local drivers without an issue
I know why it fails. It needs 2 '\' before the actual ip or 4 '\\' .
But when I try http://127.0.0.1:5000/////130.13.5.8/D/dir/
it doesnt work.
I even tried %F%F it also doesn't seem to do the trick.
#app.route('/<path:filepath>/dir/')
def get_dir(filepath):
dir_listing = ''
for entry in os.listdir(filepath):
entry_type = 'dir' if os.path.isdir(os.path.join(filepath, entry)) else 'file'
dir_listing += '{entry_name}|{entry_type}|'.format(entry_name=entry, entry_type=entry_type)
return dir_listing
For anyone having the same issue my workaround is the following
from ipaddress import ip_address
try:
ip_address(filepath.split('/')[0])
filepath = '\\\\{filepath}'.format(filepath=filepath)
except ValueError as e:
pass
When I run "bitbake core-image-sato" the following error I am facing.
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:sort_passwd(d)
0003:
File: '/home/A/poky/meta/classes/rootfs-postcommands.bbclass', lineno: 182, function: sort_passwd
0178:}
0179:
0180:python sort_passwd () {
0181: import rootfspostcommands
*** 0182: rootfspostcommands.sort_passwd(d.expand('${IMAGE_ROOTFS}${sysconfdir}'))
0183:}
0184:
0185:#
0186:# Enable postinst logging if debug-tweaks is enabled
File: '/home/A/poky/meta/lib/rootfspostcommands.py', lineno: 56, function: sort_passwd
0052: mapping = sort_file(filename, None)
0053: filename = os.path.join(sysconfdir, shadow)
0054: remove_backup(filename)
0055: if os.path.exists(filename):
*** 0056: sort_file(filename, mapping)
File: '/home/A/poky/meta/lib/rootfspostcommands.py', lineno: 22, function: sort_file
0018: name = entries[0]
0019: if mapping is None:
0020: id = int(entries[2])
0021: else:
*** 0022: id = mapping[name]
0023: new_mapping[name] = id
0024: # Sort by numeric id first, with entire line as secondary key
0025: # (just in case that there is more than one entry for the same id).
0026: lines.sort(key=lambda line: (new_mapping[line.split(b':')[0]], line))
Exception: KeyError: b'bin'
DEBUG: Python function sort_passwd finished
DEBUG: Python function do_rootfs finished
ERROR: Function failed: sort_passwd
Does any one has the idea to fix this issue.
OS:Ubuntu-16.04,Poky-Branch:SUMO
If you have changed the contents of any of the following files, which get installed to /etc, then that is likely your root cause:
passwd
shadow
group
gshadow
These files often come from the directory /files in one of your layers. It looks like one of them is ill-formatted.
There is a comment in rootfspostcommands.py, right above the point where the exception is being thrown, that reads:
# No explicit error checking for the sake of simplicity. /etc
# files are assumed to be well-formed, causing exceptions if
# not.
If nothing works for you, please do bitbake -c clean yourimagename and make the build again. This method worked for me and maybe it will help you too.
Note: do not do cleanall because it is going to delete a lot of files and hence will take more time to make the build from start.
I tried to use StanfordSegmenter to segment a piece of Chinese but encountered the captioned problem. I first downloaded Stanford Word Segmenter version 3.5.2 from http://nlp.stanford.edu/software/segmenter.shtml
Then I wrote a python:
import os
os.environ['JAVAHOME'] = "C:/Program Files/Java/jdk1.8.0_102/bin/java.exe"
from nltk.tokenize.stanford_segmenter import StanfordSegmenter
segmenter = StanfordSegmenter(path_to_jar = "./stanford-segmenter-2015-12-09/stanford-segmenter-3.6.0.jar",
path_to_slf4j = "./stanford-segmenter-2015-12-09/slf4j-api.jar",
path_to_sihan_corpora_dict = "./stanford-segmenter-2015-12-09/data",
path_to_model = "./stanford-segmenter-2015-12-09/data/pku.gz",
path_to_dict = "./stanford-segmenter-2015-12-09/data/dict-chris6.ser.gz")
sentence = u"这是斯坦福中文分词器测试"
segmenter.segment(sentence)
But I got the following error:
Error: Could not find or load main class edu.stanford.nlp.ie.crf.CRFClassifier
Where did I make mistakes? Thanks.
I think there is some implementation error. I too had the similar problem.
To resolve the error, just try doing
segmenter._stanford_jar="./stanford-segmenter-2015-12-09/stanford-segmenter-3.6.0.jar"
If this doesn't work trying giving full path of segementer jar file on segmenter._stanford_jar