CRSError while when opening shapefile using geopandas - shapefile

I am getting error when opening a shapefile that I downloaded from ArcGIs Hub. I am using the geopandas library in python and the code used is:
data = geopandas.read_file('filepath/name.shp')
I get the following error message:
CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name)
Downloaded shapefile from the following link:
(https://hub.arcgis.com/search?collection=App%2CMap)

Related

GCP/Python: Capturing actual error in subprocess.popen() while csv import from Hive to CloudSQL

I have python 3.6.8 on GNU/Linux 3.10 on GCP and I'm trying to load data from Hive to CloudSQL.
gc_cmd_import_csv_p1 = subprocess.Popen(['gcloud', 'sql', 'import', 'csv',
'{}'.format(quote(cloudsql_instance)),
'{}'.format(quote(load_csv_files)),
'--database={}'.format(quote(cloudsql_db)),
'--table={}'.format(quote(cloudsql_table_name)),
'--user={}'.format(quote(db_user_name)),
'--quiet'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
import_cmd_op, import_cmd_error = gc_cmd_import_csv_p1.communicate()
import_cmd_return_code = gc_cmd_import_csv_p1.returncode
if import_cmd_return_code:
print("""[ERROR] Unable to import data from Hive to CloudSQL.
Error description: {}
Error Code(s): {}
Issue file name: {}
""".format(import_cmd_error, import_cmd_return_code, load_csv_files))
sys.exit(9)
print("[INFO] Data Import completed from HIVE to CloudSQL.")
In case of any error above, I'm getting message like:
Error description: ERROR: (gcloud.sql.import.csv) HTTPError 403: The client is not authorized to make this request.Error Code(s): 1
But when I actually run the same import command directly as shown below:
gcloud sql import csv test-cloud-sql-instance gs://test-server-12345/app1/data/lookup_table/000000_0 --database=test_db --table=name_lookup --user=test_user --quiet
I'm getting the actual error like below:
ERROR: (gcloud.sql.import.csv) [ERROR_RDBMS] ERROR: extra data after last expected column CONTEXT: COPY name_lookup, line 16902:
I want this message
( Extra data after last expected column... line 16902:)
to be shown in python script instead of
HTTPError 403:
error. How to capture that?
Please note: There is no authentication issue as suggested by HTTP Error.
So after long discussion with GCP Admin, we have found the issue.
We tried to execute the same import command using os.system() and then again we got the HTTP error. Admin then revisited the GCP IAM documentation and created a role for P-SQL user. Issue is resolved now.

Bitbake the latest Gstreamer in Yocto Morty

I would like to bitbake the latest Gstreamer in Yocto Morty, but the error has occured and could not implement the Gstreamer.
I found the gstreamer 1.12.2 recipe at https://github.com/dv1/meta-gstreamer1.0.
So I put meta-gstreamer1.0 directory in sources directory and add BBLAYERS += " ${BSPDIR}/sources/meta-gstreamer1.0 " to build_fb/bblayers.conf.
Then I bitbaked fsl-image-gui and following errors are occured.
ERROR: /home/***/var-fslc-yocto/sources/meta-gstreamer1.0/recipes-multimedia/gstreamer/gstreamer1.0-omx_1.12.2.bb: Error executing a python function in <code>:
The stack trace of python calls that resulted in this exception/failure was:
File: '<code>', lineno: 13, function: <module>
0009:__anon_35__home_***_var_fslc_yocto_sources_poky_meta_classes_devshell_bbclass(d)
0010:__anon_108__home_***_var_fslc_yocto_sources_poky_meta_classes_sstate_bbclass(d)
0011:__anon_45__home_***_var_fslc_yocto_sources_poky_meta_classes_blacklist_bbclass(d)
0012:__anon_158__home_***_var_fslc_yocto_sources_poky_meta_classes_siteinfo_bbclass(d)
*** 0013:__anon_30__home_***_var_fslc_yocto_sources_meta_gstreamer1_0_recipes_multimedia_gstreamer_gstreamer1_0_omx_inc(d)
File: '/home/***/var-fslc-yocto/sources/meta-gstreamer1.0/recipes-multimedia/gstreamer/gstreamer1.0-omx.inc', lineno: 22, function: __anon_30__home_***_var_fslc_yocto_sources_meta_gstreamer1_0_recipes_multimedia_gstreamer_gstreamer1_0_omx_inc
0018:EXTRA_OECONF += "--disable-valgrind --with-omx-target=${GSTREAMER_1_0_OMX_TARGET}"
0019:
0020:python __anonymous () {
0021: omx_target = d.getVar("GSTREAMER_1_0_OMX_TARGET")
*** 0022: if omx_target in ['generic', 'bellagio']:
0023: # Bellagio headers are incomplete (they are missing the OMX_VERSION_MAJOR,#
0024: # OMX_VERSION_MINOR, OMX_VERSION_REVISION, and OMX_VERSION_STEP macros);
0025: # appending a directory path to gst-omx' internal OpenMAX IL headers fixes this
0026: d.appendVar("CFLAGS", " -I${S}/omx/openmax")
Exception: TypeError: getVar() missing 1 required positional argument: 'expand'
ERROR: ExpansionError during parsing /home/***/var-fslc-yocto/sources/meta-gstreamer1.0/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.12.2.bb
Traceback (most recent call last):
File "/home/***/var-fslc-yocto/sources/poky/meta/classes/base.bbclass", line 375, in __anon_656__home_***_var_fslc_yocto_sources_poky_meta_classes_base_bbclass(d=<bb.data_smart.DataSmart object at 0x7fb7a8dcff98>):
pkgconfig = (d.getVar('PACKAGECONFIG', True) or "").split()
> pn = d.getVar("PN", True)
File "/home/***/var-fslc-yocto/sources/poky/bitbake/lib/bb/data_smart.py", line 569, in DataSmart.getVar(var='PACKAGECONFIG', expand=True, noweakdefault=False, parsing=False):
def getVar(self, var, expand, noweakdefault=False, parsing=False):
> return self.getVarFlag(var, "_content", expand, noweakdefault, parsing)
File "/home/***/var-fslc-yocto/sources/poky/bitbake/lib/bb/data_smart.py", line 737, in DataSmart.getVarFlag(var='PACKAGECONFIG', flag='_content', expand=True, noweakdefault=False, parsing=False):
cachename = var + "[" + flag + "]"
> value = self.expand(value, cachename)
File "/home/***/var-fslc-yocto/sources/poky/bitbake/lib/bb/data_smart.py", line 410, in DataSmart.expand(s=" ${GSTREAMER_ORC} ${PACKAGECONFIG_GL} ${#bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} ${#bb.utils.filter('DISTRO_FEATURES', 'directfb vulkan', d)} ${#bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland egl', '', d)} bz2 curl dash dtls hls neon rsvg sbc smoothstreaming sndfile uvch264 webp ", varname='PACKAGECONFIG'):
def expand(self, s, varname = None):
> return self.expandWithRefs(s, varname).value
File "/home/***/var-fslc-yocto/sources/poky/bitbake/lib/bb/data_smart.py", line 400, in DataSmart.expandWithRefs(s=" orc gles2 egl ${#bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} ${#bb.utils.filter('DISTRO_FEATURES', 'directfb vulkan', d)} ${#bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland egl', '', d)} bz2 curl dash dtls hls neon rsvg sbc smoothstreaming sndfile uvch264 webp ", varname='PACKAGECONFIG'):
except Exception as exc:
> raise ExpansionError(varname, s, exc) from exc
bb.data_smart.ExpansionError: Failure expanding variable PACKAGECONFIG, expression was orc gles2 egl ${#bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} ${#bb.utils.filter('DISTRO_FEATURES', 'directfb vulkan', d)} ${#bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland egl', '', d)} bz2 curl dash dtls hls neon rsvg sbc smoothstreaming sndfile uvch264 webp which triggered exception AttributeError: module 'bb.utils' has no attribute 'filter'
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
I found the error "Exception: TypeError: getVar() missing 1 required positional argument: 'expand'" is fixed in Yocto 2.3(Pyro) at https://bugzilla.yoctoproject.org/show_bug.cgi?id=3314.
Furthermore, YP core says gstreamer version for Yocto Morty is 1.8.3 (see https://www.yoctoproject.org/downloads/core/morty22 updates tab).
Do these things mean that we cannot implement gstreamer 1.12.2 or later version in Yocto Morty? Are there any way to do it? Do we have to use Yocto Pyro or later version if we want to implement gstreamer 1.12?
Environment
Yocto Morty (2.2.1) https://github.com/varigit/variscite-bsp-platform/tree/morty#variscite-release-notes
PS:
I rewrite getVar and bitbake proceeded.However I got following error.Would someone help me?
ERROR: gstreamer1.0-plugins-base-1.12.2-r0 do_populate_sysroot: The recipe gstreamer1.0-plugins-base is trying to install files into a shared area when those files already exist. Those files and their manifest location are:
/home/***/var-fslc-yocto/build_fb/tmp/sysroots/imx6ul-var-dart/usr/lib/gstreamer-1.0/libgstrawparse.la
Matched in b'manifest-imx6ul-var-dart-gstreamer1.0-plugins-bad.populate_sysroot'
/home/***/var-fslc-yocto/build_fb/tmp/sysroots/imx6ul-var-dart/usr/lib/gstreamer-1.0/libgstrawparse.so
Matched in b'manifest-imx6ul-var-dart-gstreamer1.0-plugins-bad.populate_sysroot'
Please verify which recipe should provide the above files.
The build has stopped as continuing in this scenario WILL break things, if not now, possibly in the future (we've seen builds fail several months later). If the system knew how to recover from this automatically it would however there are several different scenarios which can result in this and we don't know which one this is. It may be you have switched providers of something like virtual/kernel (e.g. from linux-yocto to linux-yocto-dev), in that case you need to execute the clean task for both recipes and it will resolve this error. It may be you changed DISTRO_FEATURES from systemd to udev or vice versa. Cleaning those recipes should again resolve this error however switching DISTRO_FEATURES on an existing build directory is not supported, you should really clean out tmp and rebuild (reusing sstate should be safe). It could be the overlapping files detected are harmless in which case adding them to SSTATE_DUPWHITELIST may be the correct solution. It could also be your build is including two different conflicting versions of things (e.g. bluez 4 and bluez 5 and the correct solution for that would be to resolve the conflict. If in doubt, please ask on the mailing list, sharing the error and filelist above.
ERROR: gstreamer1.0-plugins-base-1.12.2-r0 do_populate_sysroot: If the above message is too much, the simpler version is you're advised to wipe out tmp and rebuild (reusing sstate is fine). That will likely fix things in most (but not all) cases.
ERROR: gstreamer1.0-plugins-base-1.12.2-r0 do_populate_sysroot: Function failed: sstate_task_postfunc
ERROR: Logfile of failure stored in: /home/***/var-fslc-yocto/build_fb/tmp/work/armv7at2hf-neon-fslc-linux-gnueabi/gstreamer1.0-plugins-base/1.12.2-r0/temp/log.do_populate_sysroot.99466
ERROR: Task (/home/***/var-fslc-yocto/sources/meta-gstreamer1.0/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.12.2.bb:do_populate_sysroot) failed with exit code '1'
ERROR: gstreamer1.0-plugins-base-1.12.2-r0 do_package: Error executing a python function in exec_python_func() autogenerated:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:split_gstreamer10_packages(d)
0003:
File: '/home/***/var-fslc-yocto/sources/meta-gstreamer1.0/recipes-multimedia/gstreamer/gst-plugins-package.inc', lineno: 6, function: split_gstreamer10_packages
0002:PACKAGESPLITFUNCS_append = " set_metapkg_rdepends "
0003:
0004:python split_gstreamer10_packages () {
0005: gst_libdir = d.expand('${libdir}/gstreamer-${LIBV}')
*** 0006: postinst = d.getVar('plugin_postinst')
0007: glibdir = d.getVar('libdir')
0008:
0009: do_split_packages(d, glibdir, '^lib(.*)\.so\.*', 'lib%s', 'gstreamer %s library', extra_depends='', allow_links=True)
0010: do_split_packages(d, gst_libdir, 'libgst(.*)\.so$', d.expand('${PN}-%s'), 'GStreamer plugin for %s', postinst=postinst, extra_depends='')
Exception: TypeError: getVar() missing 1 required positional argument: 'expand'
ERROR: gstreamer1.0-plugins-base-1.12.2-r0 do_package: Function failed: split_gstreamer10_packages
ERROR: Logfile of failure stored in: /home/***/var-fslc-yocto/build_fb/tmp/work/armv7at2hf-neon-fslc-linux-gnueabi/gstreamer1.0-plugins-base/1.12.2-r0/temp/log.do_package.99465
ERROR: Task (/home/***/var-fslc-yocto/sources/meta-gstreamer1.0/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base_1.12.2.bb:do_package) failed with exit code '1'
Since you are migrating recipe for older version of Yocto into a newer, you must be facing consequences of this change in Yocto: expand parameter (the second one) to getVar() and getVarFlag() has become mandatory (from bitbake user manual for morty), previously it was defaulted to False. So, you should correct all occurrences of these operations and add at least False as a second argument.

IOError while parsing a XML file

I wanted to use Python and XML to easily create objects in my Autodesk Maya Scene.
As soon as I try to parse my XML file, I get this Error :
Error: IOError: file C:\Program Files\Autodesk\Maya2016\bin\python27.zip\xml\dom\expatbuilder.py line 922: 2 #
The code that I wrote is this one :
import maya.cmds as cmds
import xml.dom.minidom as xd
class readXML():
def __init__(self):
path = "mRigger/XML/arm.rig"
print path
xFile = xd.parse(path)
init = readXML()
I only get the problem if I run it in Maya (Python 2.7) but not if I run it in PyCharm
Try switching to an absolute path. Your Maya may be running from a different working directory than PyCharm. an IOError 2 usually means 'file not found'

Python 2.x unicode & pymssql

I want to upload a string in unicode to my sql server. I'm using python 2.7.6, sqlalchemy-migrate 0.7.2, pymssql 2.1.2.
But when I saved my object I got an OperationalError from sqlalchemy
OperationalError: (OperationalError) (105, "Unclosed quotation mark
after the character string '\xd8\xa3\xd8\xb3\xd8\xb1\xd8\xa7\xd8\xb1
\xd8\xaa\xd8\xad\xd8\xaf\xd9\x8a\xd8\xaf\xd8\xa7\xd9\x84\xd9\x88\xd8
\xac\xd9\x87 - \xd9\x81\xd9\x82\xd8\xb7 \xd9\x84\xd8\xaf\xd9\x89\xd9
\x85\xd8\xad\xd9\x84\xd8\xa7\xd8\xaa \xd9\x88\xd8\xac\xd9\x88\xd9\x87
\xe2\x9c\x8e '.DB-Lib error message 105, severity 15:\nGeneral SQL
Server error: Check messages from the SQL Server\n") 'INSERT INTO...
With more detail I'm guesssing is from my Description value :
...\u0648\u062c\u0648\u0647 \u270e \U0001f38'}
I saw a big U and not u, the character is the gift unicode just before, the "\u270e" works well and show a pencil. I strongly thing is because of the 8 values versus 4 for others.
But how to prevent this error ?
The column description inside of my DB is a nvarchar(2000)
I'm using Using flask restful reqparse to parse the argument create sync the object from the DB and save it :
parser_edit.add_argument('Name',
type=unicode,
required=True,
location='json')
parser_edit.add_argument('Description',
type=unicode,
required=False,
location='json')

How to use msilib.OpenDatabase() in python

Im trying to use msi library to read some specifc informations in the database of msi file by using the function openDatabase
My code is:
db = msilib.OpenDatabase(msiFile, MSIDBOPEN_READONLY)
view = db.OpenView("SELECT Key, Name, Value FROM Registry")
while True:
view.Execute(None)
record = view.Fetch()
But I got an error:
NameError: global name 'MSIDBOPEN_READONLY' is not defined