How to fix python function in exec_python_func() autogenerated: ERROR? - python

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.

Related

how to use trigger.adddependencies in pyzabbix

i'm a newbie in python and coding,i'm trying to use pyzabbix to add trigger dependecies,but some error occusrs.
When i run
zapi.trigger.addDependencies(triggerid, dependsOnTriggerid)
an error occurs
pyzabbix.ZabbixAPIException: ('Error -32500: Application error., No permissions to referred object or it does not exist!', -32500)
i get the "triggerid" and "dependsOnTriggerid" by trigger.get:
triggerid_info = zapi.trigger.get(filter={'host': 'xx','description': 'xx'},output=['triggerid'], selectDependencies=['description'])
triggerid = triggerid_info[0]['triggerid']
dependsOnTriggerid = trigger_info[0]['dependencies'][0]['triggerid']
The results are as follws:
Traceback (most recent call last): File "E:/10.python/2019-03-07/1.py", line 14, in zapi.trigger.addDependencies(triggerid, dependsOnTriggerid) File "D:\Program Files\Python37\lib\site-packages\pyzabbix__init__.py", line 166, in fn args or kwargs File "D:\Program Files\Python37\lib\site-packages\pyzabbix__init__.py", line 143, in do_request raise ZabbixAPIException(msg, response_json['error']['code']) pyzabbix.ZabbixAPIException: ('Error -32500: Application error., No permissions to referred object or it does not exist!', -32500)
Did i get the wrong triggerid? or the i use the method in a wrong way? Thanks so much
To add a dependancy means that you need to link two different triggers (from the same host or from another one) with a master-dependent logic.
You are trying to add the dependancy triggerid -> dependsOnTriggerid, which is obtained from a supposed existing dependancy (trigger_info[0]['dependencies'][0]['triggerid']), and this makes little sense and I suppose it's the cause of the error.
You need to get both trigger's triggerid and then add the dependancy:
masterTriggerObj = zapi.trigger.get( /* filter to get your master trigger here */ )
dependentTriggerObj = zapi.trigger.get( /* filter to get your dependent trigger here */)
result = zapi.trigger.adddependencies(triggerid=dependentTriggerObj[0]['triggerid'], dependsOnTriggerid=masterTriggerObj[0]['triggerid'])
The method "trigger.addDependencies" need only one parameter,and it should be a dict or some other object/array.The following code solves the problem.
trigger_info = zapi.trigger.get(filter={xx},output=['triggerid'])
trigger_depends_info_193 = zapi.trigger.get(filter={xx},output=['triggerid'])
trigger_dependson_193 = {"triggerid": trigger_info[0]['triggerid'], "dependsOnTriggerid": trigger_depends_info_193[0]['triggerid']}
zapi.trigger.adddependencies(trigger_dependson_193)

Python syntax issue - TypeError: Required argument 'name' (pos 1) not found

I am trying to separate some files by their contents and my code looks like this
and it keeps showing me the error.
__author__ = 'Sahil Nagpal'
from pyspark import SparkContext,SparkConf
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("GEOTRELLIS").getOrCreate()
sparkcont = SparkContext.getOrCreate(SparkConf().setAppName("GEOTRELLIS"))
logs = sparkcont.setLogLevel("ERROR")
imageFile = "/mnt/imagefile/IMGFileCopy.txt"
one_meter_File = "/mnt/imagefile/one_meter/one_meter_file.txt"
_13_File = "/mnt/imagefile/13_meter/_13_File.txt"
ned19_File = "/mnt/imagefile/ned19/ned19_File.txt"
#iterate over the file
try:
with open(file=imageFile,mode="r+") as file, open(file=one_meter_File,mode='w+') as one_meter_File,open(file=_13_File,mode='w+') as _13_File,open(file=ned19_File,mode='w+') as ned19_File:
for data in file.readlines():
if("one_meter" in data):
#writing the one_meter file
one_meter_File.write(data)
elif("_13" in data):
# writing the _13 file
_13_File.write(data)
elif("ned19" in data):
# writing the ned19 file
ned19_File.write(data)
one_meter_File.close()
_13_File.close()
ned19_File.close()
file.close()
print("File Write Done")
except FileNotFoundError:
print("File Not Found")
#spark-submit --master local[*] project.py
I am having this error
with open(file=imageFile,mode="r+") as file, open(file=one_meter_File,mode='w+') as one_meter_File,open(file=_13_File,mode='w+') as _13_File,open(file=ned19_File,mode='w+') as ned19_File:
TypeError: Required argument 'name' (pos 1) not found
Can somebody please help. Thanks in advance.
As you can see here
the built-in function open doesn't take the file as a keyword argument, it needs to be set directly, your error says that the required argument "name" isn't found, it's because you need to set the name of your files directly and not as a keyword argument
i.e : open(one_meter_File, 'w+')
Edit in case of people reading this :
As stated in the comments this error only happens on python 2 because python 3 handles kwargs as normal args if the key name is right. So proofcheck your python installation, or correct it to python 2 needs, here are the python 2 docs for open

Python in ArcGIS

I wrote the following code, which results in an error and I don't know how to fix it to work.
The code is:
# Name: ClipGDBtoNewGDB.py
# Description: Take an input GDB, create a list, iterate through each
feature class, clipping it and writing it to a new GDB.
# Author: tuilbox
# Import system modules
import arcpy, os
from arcpy import env
# Set workspace
env.workspace = arcpy.GetParameterAsText(0)
arcpy.env.overwriteOutput=True
# Set local variables
fclist = arcpy.ListFeatureClasses()
clip_features = arcpy.GetParameterAsText(1)
output_directory=arcpy.GetParameterAsText(2)
xy_tolerance = ""
outgdb=os.path.join(output_directory, arcpy.GetParameterAsText(3))
if not arcpy.Exists(outgdb):
arcpy.CreateFileGDB_management(output_directory,
arcpy.GetParameterAsText(3))
# Execute Clip within for loop
for fc in fclist:
arcpy.Clip_analysis(fc, clip_features, os.path.join(outgdb, fc))
The error is: Traceback (most recent call last):
File "F:/GIS_Joseph/Lab10_Joseph/ClipGDBtoNewGDB.py", line 17, in <module>
arcpy.CreateFileGDB_management(output_directory, arcpy.GetParameterAsText(3))
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 18878, in CreateFileGDB
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000735: File GDB Location: Value is required
ERROR 000735: File GDB Name: Value is required
Failed to execute (CreateFileGDB).
Any help would be appreciated. Thank you.
With this type of question it would be helpful to let us know what parameters you are passing into your script. Have you passed a valid parameter in position 3? Use arcpy.AddMessage to double check what value you are attempting to pass to arcpy.CreateFileGDB_management.

Using Django pipeline browserify on Windows

I'm trying to follow http://gregblogs.com/how-django-reactjs-and-browserify/.
I went through some hoops to get collectstatic working but it runs without error now. However when I try to load the page which contains my react component, another compilation process kicks in (I thought collectstatic will pre-process everything and nothing will have to compile run-time). It requires some hack to make it work right now (https://github.com/j0hnsmith/django-pipeline-browserify/issues/14). But even after that patch, unfortunately this compilation errors out. Although the command seems OK now: if I execute
C:\Users\JohnSmith\node_modules\.bin\browserify.cmd -t babelify --deps C:\Users\JohnSmith\Documents\test\company\static\dashboard\js\react_test_dashboard_widget.browserify.js
it runs without an error and produces a dependency JSON. When the same command is executed as a sub-process by Django/Pipeline, it errors out saying
Error: Cannot find module ' babelify' from 'C:\Users\JohnSmith\Documents\test\company
How to overcome that?
packages.json snippet
"dependencies": {
"babel-cli": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"yuglify": "^0.1.4",
"babelify": "^7.3.0",
"browserify": "^13.0.1",
"jquery": "^2.2.0",
"react": "^15.2.0"
},
"devDependencies": {
"babel-plugin-transform-class-properties": "^6.10.2",
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-preset-es2016": "^6.11.0",
"babel-preset-react": "^6.11.1"
}
requirements snippet:
...
django-pipeline==1.6.6
django-pipeline-browserify==0.4.1
futures==3.0.5
...
Some settings (BTW https://github.com/j0hnsmith/django-pipeline-browserify/issues/15):
PIPELINE["CSS_COMPRESSOR"] = "pipeline.compressors.NoopCompressor"
PIPELINE["JS_COMPRESSOR"] = "pipeline.compressors.NoopCompressor"
PIPELINE['SASS_BINARY'] = 'C:\\Ruby22-x64\\bin\\sass.bat'
PIPELINE['BABEL_BINARY'] = 'c:\\Users\\JohnSmith\\node_modules\\.bin\\babel.cmd'
PIPELINE['BROWSERIFY_BINARY'] = 'c:\\Users\\JohnSmith\\node_modules\\.bin\\browserify.cmd'
PIPELINE_BROWSERIFY_BINARY = PIPELINE['BROWSERIFY_BINARY']
if DEBUG:
PIPELINE["BROWSERIFY_ARGUMENTS"] = '-t babelify'
PIPELINE_BROWSERIFY_ARGUMENTS = PIPELINE["BROWSERIFY_ARGUMENTS"]
(last one was needed for compilers!)
My system: Win 10, Python 2.7, Django 1.8
Tell me what else should I specify
Update: the error message comes from Node itself. See the call stack below. Note, that here I tried to explicitly specify the transformation JS file instead of a module name (this also works well from the command line but not well in the app):
CompilerError: ['c:\\Users\\JohnSmith\\node_modules\\.bin\\browserify.cmd', '-t c:\\Users\\JohnSmith\\Documents\\test\\node_modules\\babelify\\index.js', u'--deps C:\\Users\\JohnSmith\\Documents\\test\\company\\static\\dashboard\\js\\react_test_dashboard_widget.browserify.js'] exit code 1
Error: Cannot find module ' c:\Users\JohnSmith\Documents\test\node_modules\babelify\index.js' from 'C:\Users\JohnSmith\Documents\test\company'
at c:\Users\JohnSmith\node_modules\resolve\lib\async.js:46:17
at process (c:\Users\JohnSmith\node_modules\resolve\lib\async.js:173:43)
at ondir (c:\Users\JohnSmith\node_modules\resolve\lib\async.js:188:17)
at load (c:\Users\JohnSmith\node_modules\resolve\lib\async.js:69:43)
at onex (c:\Users\JohnSmith\node_modules\resolve\lib\async.js:92:31)
at c:\Users\JohnSmith\node_modules\resolve\lib\async.js:22:47
at FSReqWrap.oncomplete (fs.js:82:15)
This advises me that maybe the problem is that Node itself captures the t parameter and doesn't pass it to browserify. For sure this issue might be crucial: https://github.com/j0hnsmith/django-pipeline-browserify/issues/14
I overrode the https://github.com/j0hnsmith/django-pipeline-browserify/blob/master/pipeline_browserify/compiler.py#L55
command = "%s %s %s --deps %s" % (
getattr(settings, 'PIPELINE_BROWSERIFY_VARS', ''),
getattr(settings, 'PIPELINE_BROWSERIFY_BINARY', '/usr/bin/env browserify'),
getattr(settings, 'PIPELINE_BROWSERIFY_ARGUMENTS', ''),
self.storage.path(infile),
)
with
command = (
getattr(settings, 'PIPELINE_BROWSERIFY_BINARY', '/usr/bin/env browserify'),
getattr(settings, 'PIPELINE_BROWSERIFY_ARGUMENTS', ''),
"--deps %s" % self.storage.path(infile),
)
'cause the pipeline compiler code expects tuples. By he original code it received one complete string, but then it dissected it to individual characters, thinking that all of them are arguments, see https://github.com/jazzband/django-pipeline/blob/master/pipeline/compilers/init.py#L108
argument_list = []
for flattening_arg in command:
if isinstance(flattening_arg, string_types):
argument_list.append(flattening_arg)
else:
argument_list.extend(flattening_arg)
This would lead to a disaster later:
CompilerError: [Error 87] The parameter is incorrect
My co-worker tried to get it working on OSX too, but we gave up. We just short-circuited the is_outdated to always return true. The is_outdated contains some info in the comments about that anyway (https://github.com/j0hnsmith/django-pipeline-browserify/blob/master/pipeline_browserify/compiler.py#L41):
"WARNING: It seems to me that just generating the dependencies may take just as long as actually compiling, which would mean we would be better off just forcing a compile every time."
The way to shortcircuit is to define your own compiler and register that one.
PIPELINE['COMPILERS'] = (
'pipeline.compilers.sass.SASSCompiler',
# 'pipeline_browserify.compiler.BrowserifyCompiler',
'company.utils.compilers.BrowserifyCompiler',
...
)
Where
class BrowserifyCompiler(BrowserifyCompiler):
def is_outdated(self, infile, outfile):
return True
Last comment and the sheer fact that noone complained about this before makes me wonder about the state of the project...
https://github.com/j0hnsmith/django-pipeline-browserify/issues/14

How to create multiple directories in xbmc/kodi addon?

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

Categories

Resources