I'm trying to get AutoConfigBuilder working, but I'm having no luck. I'm using SCons v2.3.4.
My SConstruct:
env = Environment(tools = ['default','UnTar','AutoConfig'])
configured = env.AutoConfig('libpcap-1.6.2')
Output:
scons: Reading SConscript files ...
TypeError: Tried to lookup Dir 'libpcap-1.6.2' as a File.:
File "/home/jreinhart/git_repos/scons-test/autoconf_builder/SConstruct", line 4:
configured = env.AutoConfig('libpcap-1.6.2')
File "/usr/lib/scons/SCons/Environment.py", line 260:
return MethodWrapper.__call__(self, target, source, *args, **kw)
File "/usr/lib/scons/SCons/Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "/usr/lib/scons/SCons/Builder.py", line 633:
return self._execute(env, target, source, OverrideWarner(kw), ekw)
File "/usr/lib/scons/SCons/Builder.py", line 554:
tlist, slist = self._create_nodes(env, target, source)
File "/usr/lib/scons/SCons/Builder.py", line 484:
slist = env.arg2nodes(source, source_factory)
File "/usr/lib/scons/SCons/Environment.py", line 486:
v = node_factory(self.subst(v, **kw))
File "/usr/lib/scons/SCons/Node/FS.py", line 1340:
return self._lookup(name, directory, File, create)
File "/usr/lib/scons/SCons/Node/FS.py", line 1319:
return root._lookup_abs(p, fsclass, create)
File "/usr/lib/scons/SCons/Node/FS.py", line 2224:
result.must_be_same(klass)
File "/usr/lib/scons/SCons/Node/FS.py", line 627:
(self.__class__.__name__, self.path, klass.__name__))
Any advice on how to start working on this recipe? I'm not even sure what exactly is failing here. I'm assuming for some reason SCons thinks that when I call the builder like env.AutoConfig('libpcap-1.6.2'), that I'm referring to a file, not a directory.
I've posted this to the scons mailing list, but I'd imagine Stack Overflow gets more traffic.
From what I could find this is a bug in SCons itself. I'm not sure if/when it'll be fixed.
This is my workaround: force the parameter to be a SCons Dir object because SCons isn't getting it right.
Try this:
env.AutoConfig(env.Dir('libpcap-1.6.2'))
Related
I have already created an account in picovoice and recieved an access key, but when I try to put the path of my ppn file, it shows an error:
`
[ERROR] loading keyword file at 'C:\Users\Priyam\Desktop\hey keyazip' failed with 'IO_ERROR'
Traceback (most recent call last):
File "e:\Personal Project\import struct.py", line 13, in <module>
porcupine = pvporcupine.create(access_key='access key',
File "C:\Users\Priyam\AppData\Roaming\Python\Python310\site-packages\pvporcupine\__init__.py", line 77, in create
return Porcupine(
File "C:\Users\Priyam\AppData\Roaming\Python\Python310\site-packages\pvporcupine\porcupine.py", line 158, in __init__
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
pvporcupine.porcupine.PorcupineIOError
the code is:
`
porcupine=None
paud=None
audio_stream=None
try:
access_key="access key"
porcupine = pvporcupine.create(access_key='access key',
keyword_paths=['C:\\Users\Priyam\Desktop\hey keyazip'],keywords=['hey keya']) #pvporcupine.KEYWORDS for all keywords
paud=pyaudio.PyAudio()
audio_stream=paud.open(rate=porcupine.sample_rate,channels=1,format=pyaudio.paInt16,input=True,frames_per_buffer=porcupine.frame_length)
while True:
keyword=audio_stream.read(porcupine.frame_length)
keyword=struct.unpack_from("h"*porcupine.frame_length,keyword)
keyword_index=porcupine.process(keyword)
if keyword_index>=0:
print("hotword detected")
finally:
if porcupine is not None:
porcupine.delete()
if audio_stream is not None:
audio_stream.close()
if paud is not None:
paud.terminate()
`
I tried the code above and the code provided by picovoice itself, yet I am facing the same issues
It looks like Porcupine is having trouble finding your keyword file: [ERROR] loading keyword file at 'C:\Users\Priyam\Desktop\hey keyazip' failed with 'IO_ERROR'.
The Picovoice console provides the keyword inside a compressed .zip file. You will need to decompress the file and in your code update the path to lead to the .ppn file located inside. For example: C:\\Users\Priyam\Desktop\hey-keya_en_windows_v2_1_0\hey-keya_en_windows_v2_1_0.ppn
I have been digging through questions/answers for the BadZipFile exception when calling read_excel() using the openpyxl engine. I looked at my error stack and dug into the Python files and it looks like ZipFile.py is being very strict when validating an archive. It is looking for an EOCD (end of central directory) signature in my XLSX archive file.
When unzipping an archive, if the EOCD cannot be found or validated, there is supposed to be an error thrown when calling unzip in Linux, but I am not seeing it. I am unsure whether the EOCD is there/correct or not (anyone know of a tool to check?).
However, from looking through my stack (below) I am examining what is happening in openpyxl/reader/excel.py. At line 67, the _validate_archive function is defined. I am wondering about the examination for a "file like object".
My use case is an AWS Lambda function which has an HTTP endpoint. I POST an Excel file (I am testing with Postman and using the binary body for the request where I select my Excel file) to the endpoint. The function needs to handle both CSV and XLSX. I include a custom header in which I specify the original file name. I split the filename, look at the extension, and either call read_csv or read_excel. read_csv is working great.
Either way, the file is coming in as base64. For an XLSX file, Pandas handles this OK - up until we get to _validate_archive... What I am unsure of is how the "file like object" check at line 76...
is_file_like = hasattr(filename, 'read')
... interacts with the type by which the Base64 is handled. I am trying straight string (event["body"]), the bytes() object, the BytesIO class, and the StringIO class, all to the same BadZipFile exception.
So... is it possible in Pandas/Openpyxl to suppress the validation of the archive? I want to be able to call read_excel() but not have the archive validated and see what happens.
My error stack:
"Error: (<class 'zipfile.BadZipFile'>, BadZipFile('File is not a zip file'),
<traceback object at 0x7f1019589dc0>)\r\n<class 'zipfile.BadZipFile'>\r\n
File is not a zip file\r\nTraceback (most recent call last):\n
File "/var/task/lambda_function.py", line 20, in lambda_handler\n inv = pd.read_excel( bufferedString, engine='openpyxl', index_col=0 )\n
File "/opt/python/pandas/util/_decorators.py", line 311, in wrapper\n return func(*args, **kwargs)\n
File "/opt/python/pandas/io/excel/_base.py", line 457, in read_excel\n io = ExcelFile(io, storage_options=storage_options, engine=engine)\n
File "/opt/python/pandas/io/excel/_base.py", line 1419, in init\n self._reader = self._engines[engine](self._io, storage_options=storage_options)\n
File "/opt/python/pandas/io/excel/_openpyxl.py", line 525, in init\n super().init(filepath_or_buffer, storage_options=storage_options)\n
File "/opt/python/pandas/io/excel/_base.py", line 518, in init\n self.book = self.load_workbook(self.handles.handle)\n
File "/opt/python/pandas/io/excel/_openpyxl.py", line 536, in load_workbook\n return load_workbook(\n
File "/opt/python/openpyxl/reader/excel.py", line 315, in load_workbook\n reader = ExcelReader(filename, read_only, keep_vba,\n
File "/opt/python/openpyxl/reader/excel.py", line 124, in init\n self.archive = _validate_archive(fn)\n
File "/opt/python/openpyxl/reader/excel.py", line 96, in _validate_archive\n archive = ZipFile(filename, 'r')\n
File "/var/lang/lib/python3.9/zipfile.py", line 1264, in init\n self._RealGetContents()\n
File "/var/lang/lib/python3.9/zipfile.py", line 1331, in _RealGetContents\n
raise BadZipFile("File is not a zip file")\n
zipfile.BadZipFile: File is not a zip file\n"
i'm on nixos 20.09 and try to build godot-3.2.3-stable with support for C#.
I'm following the instruction on the godot docs, which states that one first has to enable the mono module and then generate the mono-glue. I tried to adapt the default.nix of the NixOS/nixpkgs repository to my needs but failed.
What i tried is to first generate the glue like mentioned in the godot docs and then compile with C# support.
with import <nixpkgs> {};
let options = {
pulseaudio = true;
};`
in
stdenv.mkDerivation rec {
name = "tools_";
version = "3.2.3";
src = ./godot-3.2.3-stable.tar.gz;
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ scons mono6 msbuild dotnetPackages.Nuget xorg.libX11 xorg.libXcursor
xorg.libXinerama xorg.libXrandr xorg.libXrender xorg.libXi xorg.libXext
xorg.libXfixes freetype openssl alsaLib libpulseaudio libGLU zlib yasm
];
patches = [
./pkg_config_additions.patch
./dont_clobber_environment.patch
];
enableParallelBuilding = true;
sconsFlags = "target=release_debug platform=x11 tools=yes module_mono_enabled=yes mono_glue=no";
preConfigure = ''
sconsFlags+=" ${lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "${k}=${builtins.toJSON v}") options)}"
'';
outputs = [ "out" ];
installPhase = ''
mkdir -p "$out/bin"
cp bin/godot.* $out/bin/godot
'';
}
But if i run this with nix-build i get the error:
Checking for `thread_local` support... supported
Mono root directory not found. Using pkg-config instead
/nix/store/vnyfysaya7sblgdyvqjkrjbrb0cy11jf-bash-4.4-p23/bin/sh: pkg-config: command not found
OSError: 'pkg-config monosgen-2 --libs-only-L' exited 127:
File "/build/godot-3.2.3-stable/SConstruct", line 617:
SConscript("modules/SCsub")
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Script/SConscript.py", line 661:
return method(*args, **kw)
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Script/SConscript.py", line 598:
return _SConscript(self.fs, *files, **subst_kw)
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Script/SConscript.py", line 287:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/build/godot-3.2.3-stable/modules/SCsub", line 21:
SConscript(name + "/SCsub") # Built-in.
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Script/SConscript.py", line 661:
return method(*args, **kw)
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Script/SConscript.py", line 598:
return _SConscript(self.fs, *files, **subst_kw)
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Script/SConscript.py", line 287:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "/build/godot-3.2.3-stable/modules/mono/SCsub", line 34:
mono_configure.configure(env, env_mono)
File "/build/godot-3.2.3-stable/modules/mono/build_scripts/mono_configure.py", line 351:
tmpenv.ParseConfig("pkg-config monosgen-2 --libs-only-L")
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Environment.py", line 1612:
return function(self, self.backtick(command))
File "/nix/store/ypb1lsl610mw3s76p232hjmnhwakjb06-scons-4.0.1/lib/python3.8/site-packages/SCons/Environment.py", line 599:
raise OSError("'%s' exited %d" % (command, status))
builder for '/nix/store/acpp99hr7q92a7j1bk2nga00n4v8za7z-tools_.drv' failed with exit code 2
error: build of '/nix/store/acpp99hr7q92a7j1bk2nga00n4v8za7z-tools_.drv' failed
I'm sorry but i'm totally lost there, since this is my first derivation i am trying to build. I have already searched the nixpkgs manual but couldn't solve my problem. Probably due to the fact that i'm not exactly sure what i am looking for. Also i was asking myself if this is going to work anyways since the godot docs state that after generating the glue one has to:
### Build binaries normally
# Editor
scons p=x11 target=release_debug tools=yes module_mono_enabled=yes
and i don't know if i could then simply rerun the above mentioned derivation with the appropriate sconsFlags or if and how i could simply write one file which does the same job done.
If someone could help me and point me in the right direction so that i at least would know what i exactly have to search for i would very much appreciate it. Thanks in advance.
Am just having four weeks of experience in Python. Creating a tool using Tkinter to paste a new company logo on top of the existing images.
The Below method is to, get all images in the given directory and paste the new logo on the initial level. Existing image, edited image, x-position, y-position, a preview of the image and few data's are store in global instance self.images_all_arr.
def get_img_copy(self):
self.images_all_arr = []
existing_img_fldr = self.input_frame.input_frame_data['existing_img_folder']
for file in os.listdir(existing_img_fldr):
img_old = Image.open(os.path.join(existing_img_fldr, file))
img_new_copy = img_old.copy()
self.pasteImage(img_new_copy, initpaste=True) #process to paste new logo.
view_new_img = ImageTk.PhotoImage(img_new_copy)
fname, fext = file.split('.')
formObj = {
"fname": fname,
"fext": fext,
"img_old": img_old,
"img_new": img_new_copy,
"img_new_view": view_new_img,
"add_logo": 1,
"is_default": 1,
"is_opacityImg": 0,
"pos_x": self.defult_x.get(),
"pos_y": self.defult_y.get()
}
self.images_all_arr.append(formObj)
After previewing each image in Tkinter screen, doing some adjustment in position x and y(updating pos_x and pos_y in the list self.images_all_arr) depends upon the necessity.
Well, once all done. Need to save the edited images. Below method to save images, iterating the list self.images_all_arr and call save method as img['img_new'].save(dir_output) since img['img_new'] has updated image.
def generate_imgae(self):
if len(self.images_all_arr):
dir_output = 'xxxxx'
for img in self.images_all_arr:
print(img['img_new'])
img['img_new'].save(dir_output)
print('completed..')
But it returns below error,
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\PIL\Image.py", line 2138, in save
format = EXTENSION[ext]
KeyError: ''
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\tkinter_init_.py", line 1883, in call
return self.func(*args)
File "C:\Users\662828\WORKSPACE\AAA_python_projects\AMI_automation_poc2\position_and_images.py", line 241, in generate_imgae
img['img_new'].save(dir_output)
File "C:\Program Files (x86)\Python38-32\lib\site-packages\PIL\Image.py", line 2140, in save
raise ValueError("unknown file extension: {}".format(ext)) from e
ValueError: unknown file extension:
dir_output doesn't contain the file extension, its just xxxxx. You need to specify what image file format you want. the error tells us this by saying "unknown file format".
Basically, you either need to include the extension in the file name, or pass it as the next parameter in image.save. You can check out the documentation here
eg.
image.save('image.png')
or
image.save('image', 'png')
The below code solved my issue. By giving the exact directory, filename and extension of the image as param to the method image.save(). Here the result of opfile is, C:\Users\WORKSPACE\AAA_python_projects\test\valid.png.
def generate_imgae(self):
if len(self.images_all_arr):
dir_output = r"C:\Users\WORKSPACE\AAA_python_projects\test"
if not os.path.isdir(dir_output):
os.mkdir(dir_output)
for img in self.images_all_arr:
opfile = os.path.join(dir_output, '{}.{}'.format(img['fname'], img['fext'] ))
img['img_new'].save(opfile)
print('completed..')
Thanks #dantechguy
I tried to use Rasa's ReminderScheduled as specified in the docs. I'm using Windows 10 with the Ubuntu subsystem to run the code. The code that calls the reminder is the following:
export_timeout = datetime.timedelta(seconds=30)
class ActionGiveListProducts(Action):
def name(self):
return 'action_give_list_products'
def run(self, dispatcher, tracker, domain):
s = getInfo("listeproduits")
dispatcher.utter_message(s)
return [ReminderScheduled("action_export_logs", datetime.datetime.now() + export_timeout)]
Executing this Action causes the following error:
Traceback (most recent call last):
File "bot.py", line 136, in <module>
run()
File "bot.py", line 108, in run agent.handle_channel(ConsoleInputChannel())
File "/usr/local/lib/python3.5/dist-packages/rasa_core/agent.py", line 126, in handle_channel
processor.handle_channel(input_channel)
File "/usr/local/lib/python3.5/dist-packages/rasa_core/processor.py", line 60, in handle_channel
input_channel.start_sync_listening(self.handle_message)
File "/usr/local/lib/python3.5/dist-packages/rasa_core/channels/console.py", line 52, in start_sync_listening
self._record_messages(message_handler)
File "/usr/local/lib/python3.5/dist-packages/rasa_core/channels/console.py", line 45, in _record_messages
self.sender_id))
File "/usr/local/lib/python3.5/dist-packages/rasa_core/processor.py", line 83, in handle_message
self._predict_and_execute_next_action(message, tracker)
File "/usr/local/lib/python3.5/dist-packages/rasa_core/processor.py", line 262, in _predict_and_execute_next_action
dispatcher)
File "/usr/local/lib/python3.5/dist-packages/rasa_core/processor.py", line 312, in _run_action
self._schedule_reminders(events, dispatcher)
File "/usr/local/lib/python3.5/dist-packages/rasa_core/processor.py", line 296, in _schedule_reminders
replace_existing=True)
File "/usr/local/lib/python3.5/dist-packages/apscheduler/schedulers/base.py", line 413, in add_job
'trigger': self._create_trigger(trigger, trigger_args),
File "/usr/local/lib/python3.5/dist-packages/apscheduler/schedulers/base.py", line 907, in _create_trigger
return self._create_plugin_instance('trigger', trigger, trigger_args)
File "/usr/local/lib/python3.5/dist-packages/apscheduler/schedulers/base.py", line 892, in _create_plugin_instance
return plugin_cls(**constructor_kwargs)
File "/usr/local/lib/python3.5/dist-packages/apscheduler/triggers/date.py", line 20, in __init__
timezone = astimezone(timezone) or get_localzone()
File "/usr/local/lib/python3.5/dist-packages/apscheduler/util.py", line 86, in astimezone
'Unable to determine the name of the local timezone -- you must explicitly '
ValueError: Unable to determine the name of the local timezone -- you must explicitly
specify the name of the local timezone.
Please refrain from using timezones like EST to prevent problems with daylight saving time.
Instead, use a locale based timezone name (such as Europe/Helsinki).
I tried to set the timezone in the launch code as following:
os.environ['TZ'] = 'Europe/London'
time.tzset()
but this didn't change anything. I also searched for other solutions, but found nothing relevant.
Does someone know what causes this error exactly and if there is way to eliminate it?
I assume you run this in a Linux environment (as I had the same error), so try to set the following:
keep as you had it in the python code:
keepos.environ['TZ'] = 'Europe/London'
and also set the timezone in the os:
sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime
It worked for me.
The following works on the Ubuntu subsystem for Windows:
sudo cp /usr/share/zoneinfo/America/New_York /etc/localtime
TZ=America/New_York rasa x
You can also make the TZ environment variable permanent by adding export TZ=America/New_York in your ~/.bashrc file.