I'm having an issue with a TCL hook script.
There's a *.vhd file that I need to open using this line of code:
set f [open C:/Users/myusername/Desktop/myfile.vhd]
this file is set to be part of xil_defaultlib and I try to access it using the library, since the TCL script should be for others to use and they won't be able to access the file using the path I mentioned above.
I've tried choosing the work library instead and referencing the file the following way:
set f [open work.myfile.vhd]
but the TCL console writes:
couldn't open "work.myfile.vhd": no such file or directory
What would be the correct way to open the file using the work or xil_defaultlib libraries as the path to it?
Thanks in advance.
Related
I'm trying to write a script that has to access a DLL file (MySql.Data.dll) from a folder in the Desktop(New Folder). I use the variable $DLLFilePath = $home + '\Desktop\New Folder\MySql.Data.dll') to set the path. But it's not working with [void][system.reflection.Assembly]::LoadFrom($DLLFilePath) giving the error Exception calling "LoadFrom" with "1" argument(s): "Illegal characters in path.".
Is there someway to get the DLL file loaded in LoadFrom?
Looks like PowerShell doesn't allow strings or variables in LoadFrom(). So I used a simple workaround:
Copy the DLL file to a new location like C: drive
Hardcode the path to the DLL file in LoadFrom()
Delete the copied file in C: after use.
I am learning about python and I want to open a html file inside a zip file. I'm reading tutorials and following documentation I found online for python 3.6 but I can't print the content of the news.html document which is inside the John.zip folder
import zipfile
file = zipfile.ZipFile("John.zip", "r")
with file('John.zip') as myzip:
with myzip.open("news.html") as myfile:
print(myfile.read())
When I start without debugging it shows "TypeError: 'ZipFile' object is not callable
But I can't fix this. I tried simpler things such as trying to open it the way you open a .txt file
file=open("John.zip/news.html")
print(file.read())
this didn't work either
What you are doing is storing a ZipFile as an object named it "file". Then, in the line beginning with "with", you're calling it as if it were a function. That is why you received the TypeError, because that object you named "file" is not a callable function.
Get rid of the line where you stored it as "file", and try something like this:
with zipfile.ZipFile('John.zip', 'r') as myzip:
Source:
Python Docs: https://docs.python.org/3/library/zipfile.html#zipfile-objects
I guess you have overridden the builtin function "file" by setting the global variable "file".
just print the file see whats in it.
TypeError: 'ZipFile' object is not callable
I had the similar problem, in my case i was working on google colab and i was getting this error but i updated the tensorflow version to v2.0.0 from v1.5.0 and it worked.
If the problem is not resoöved even after updatíng the tensorflow then try update to higher python version or lower python version sometimes, hope it would be solved.
I have a tcl script named main.tcl in a folder called App. One of the lines in the script uses a command from the twapi module (that line is actually in a proc and I'm trying to minimize the app to system tray when a user closes the app through the 'X' window button):
package require twapi
# ... code here
set hand [twapi::load_icon_from_file tclkit.ico]
# ... code here
The file tclkit.ico is in the same directory as the script (i.e. in the folder App).
When main.tcl is run through wish, the script works without any issues, but after wrapping it into an executable through command line,
> tclkit sdx.kit wrap App -runtime tclsh863.exe
the executable raises an error, notably that the icon file could not be found:
The system cannot find the file specified.
The system cannot find the file specified.
while executing
"LoadImage $hmod $path $type $opts(width) $opts(height) $flags"
(procedure "twapi::_load_image" line 18)
invoked from within
"twapi::load_icon_from_file tclkit.ico"
(procedure "min_to_tray" line 2)
invoked from within
"min_to_tray"
(command for "WM_DELETE_WINDOW" window manager protocol)
The current workaround right now is to have a copy of the tclkit.ico file in the same directory as the .exe but I want to avoid that as much as possible and only have the standalone .exe file. I tried using the full path with:
set hand [twapi::load_icon_from_file [file join [pwd] App.exe tclkit.ico]]
which normally works when I want to read a file (.txt, .png files, etc.) within the .exe, without success.
So basically, is there a way to enable the .exe to load the .ico file from within itself or another workaround that will not require some dependence on a file outside the .exe app?
The core issue is that the relevant Windows API actually takes a filename, and not something that it's more easy to wrap loading-from-archive around (such as a buffer). This means that you have to copy the file out of the archive somewhere and then pass that name to the system call. This is in fact what Tcl does internally for load when it's pulling the DLL from a source that isn't directly visible to the OS; it doesn't do it automatically for TWAPI though, as that library takes the philosophical position of being just a thin wrapper and letting the caller handle the consequences (which does mean you can easily do more tricks, provided you're inventive).
I suggest copying the file to a temporary file somewhere (i.e., the standard location for these things; Tcl 8.6 has file tempfile to help with this sort of trick) and then passing the full filename into the TWAPI call. I think everywhere in the Windows API that you could pass a simple filename in, you can also pass a full filename. (That's actually very convenient…)
I have a macro done by LibreOffice Calc it's a french version of OpenOffice.
This macro opens a csv file without the dialog box. But I'd like to execute it via Batch.
The ideia is, use system() commmand in matlab to run this macro.
This macro is in addressed as Importcsv.ods --> Standard --> Module1 --> CSVOpen
How should I put the complete address of the file, and where put the name of the csv file I want to open?
Many thanks,
Bruno
PS: I'd forgot something. I want to run this in Calc and there, do anything I want. Because this file will be sabed in xls to be used in SolidWorks (CAD software).
I've continued looking for it, and I found an answer to execute the macro.
We should open the repertory in cmd where is the file with the macro ,put the address of the exe, write the name of it and the reference of the macros. I'll do an example:
"C:\Program Files\OpenOffice.org 3\program\soffice.exe" FileName.ods "macro:///Standard.Module1.MacroName"
if wanted directly from matlab, is just use the system('') command.
"c:\Program Files (x86)\OpenOffice 4\program\swriter.exe" -invisible "macro:///Standard.Module1.Main"
or from another source
"c:\Program Files (x86)\OpenOffice 4\program\swriter.exe" -nologo -norestore -nolockcheck "macro:///Standard.Module1.Main"
I'm new to Tcl and I have a script that is wrapped using freewrapTCLSH.exe
At first, when started, the program complained about not finding a package
I edited the line the seems to "include" it to
lappend auto_path ../../lib/crc
This worked fine and the .exe started without issues. But then I moved the exe to another folder and it started complaining again. I thought that once the exe was created everything would be done. But it doesn't seem to handle this very well.
At first the entire path to the lib was hard coded into the script and then everything worked fine. But since we can't rely on the exe always being built in the same folder this had to be changed.
Any ideas on how to get around this annoying problem?
../../lib/crc is interpreted using the current working directory each time a package is searched. Having this thing it your ::auto_path is almost always not what you want.
I use [file dirname [info script]] to get a directory of currently sourced Tcl file, adding a relative path to some lib/crc with file join, ensuring to get a full pathname with file normalize. The result of file normalize is what I add to ::auto_path (or remember for future use in some other way):
lappend ::auto_path [file normalize [file join [file dirname [info script]] ../mylib]]
It might be obvious, but still: info script returns the path to file currently being sources, not the path somehow remembered when the file containing a call to it was sourced. If you want to get the current script location, ensure it happens at right time (e.g. do it at top level).
You should deliver the required package (and the dependencies of that package) into your exe.
usually this only involves copying the directory of the required packages to the lib folder in your vfs.