Re: [Gpsbabel-misc] Setting temp path without Windows environmental variable
GPSBabel converts and transfers data like waypoints, tracks & routes.
Brought to you by:
robertl
|
From: Robert L. <rob...@gp...> - 2017-09-11 21:05:11
|
It's totally weird that reading a device writes a file, but it looks like this format reads from the device, writes to a file, then reads from that file to do the real work. I suspect that approximately nobody wants that file to be left over, so it should probably be removed on exit (perhaps optionally) It's not great for security to leave temp files around like that, either. I'll see if I can find an mtk device and make this code a little more normal. But our release schedule (none, currently) won't match your so you should probably tame your Python needs. Do you really have so many devices attached that you're reading them in parallel? That seems interesting. RJL On Mon, Sep 11, 2017 at 1:53 PM, philshem <phi...@zo...> wrote: > Hi All > > Thanks for your reply Robert, and the nice welcome to the list. > > I’m also not a Windows dev, and actually use my own Python wrapper scripts > to scan COM ports and generate and run the GPSBabel command line > executable. To run GPSBabel as multiple processes, I need to hijack the > environmental variable TMP for each process. > > It works from two cmd.exe sessions, but not yet with Python. I found this > question <https://stackoverflow.com/a/14533902/2327328> on StackOverflow > useful, and used it to open a new question > <https://stackoverflow.com/q/46162094/2327328>. None of this really > solves the issue of GPSBabel code writing data.bin files for MTK loggers. > > I've looked into the GPSBabel source code and see where GPSBabel creates > the temp path and file name - function GetTempName() at line 300 of > mtk_logger.cc > <https://github.com/gpsbabel/gpsbabel/blob/master/mtk_logger.cc>. > > Would the fix be as easy as this? > > current: > > static const char* GetTempName(bool backup) { > const char kData[]= "data.bin"; > const char kDataBackup[]= "data_old.bin"; > > QString t = QDir::tempPath(); > t += QDir::separator(); > t += backup ? kDataBackup : kData; > return t.toLatin1(); > } > > suggested: > > static const char* GetTempName(bool backup) { > QTemporaryFile kFile; // create a unique temp file > > QString t = QDir::tempPath(); > t += QDir::separator(); > t += kFile; > return t.toLatin1(); > } > > Or is the hardcoded data.bin needed somewhere else? > > Regards > Philip > > p.s. also not a C++ developer :) > > > > On 7 Sep 2017, at 23:56, Robert Lipe <rob...@gp...> wrote: > > Hi, Phillip and welcome. > > You're right. The code gets the temporary directory from the OS, but then > doesn't use QTemporaryFile <http://doc.qt.io/qt-5/qtemporaryfile.html> to > ensure that the file within it is unique. I can't dive into the code right > now, but it's just so hokey that that format alone (I think) writes a file > while you're reading. > > If you're automating this, I'd think that scripting this in a batch file > would look something like > mkdir temp/1 temp/2 temp/3 > set TMP=C:\temp\1\ && gpsbabel.exe -w -t -i mtk -f COM6 -o gpx1 -F > test.gpx > set TMP=C:\temp\*2*\ && gpsbabel.exe -w -t -i mtk -f COM7 -o *gpx2* > -F test.gpx > set TMP=C:\temp\*3*\ && gpsbabel.exe -w -t -i mtk -f COM8 -o *gpx3* > -F test.gpx > ...but that does them one at a time and I'm guessing the real goal is to > do them at the same time. Again, making this up because I'm not a windows > dev, bug I can read stack overflow... > start cmd /c call set TMP=C:\temp\1\ && gpsbabel.exe -w -t -i mtk -f > COM6 -o gpx1 -F test.gpx > start cmd /c set TMP=C:\temp\*2*\ && gpsbabel.exe -w -t -i mtk -f > COM7 -o *gpx2* -F test.gpx > start cmd /c set TMP=C:\temp\*3*\ && gpsbabel.exe -w -t -i mtk -f > COM8 -o *gpx3* -F test.gpx > > but there may be some quoting rules that I'm breaking. Start with > something like https://stackoverflow.com/questions/649634/how-do-i- > run-a-bat-file-in-the-background-from-another-bat-file > > Really, this code just needs to be fixed to Not Do This. Any takers? > > RJL > > On Thu, Sep 7, 2017 at 2:49 PM, Philip Shemella <phi...@zo...> wrote: > > > Hi All > > When I run the code to extract from MTK and convert to GPX, the code reads > my Windows environmental variable TMP and write a temp file "data.bin" in > that folder (at least this is what I've learned from a bit of reverse > engineering). I can set a temporary new path for TMP before running > gpsbabel.exe from the command line: > > set TMP=C:\temp\ && gpsbabel.exe -w -t -i mtk -f COM6 -o gpx -F > test.gpx > > Is there a built-in way to define the temp folder, without using Windows > environmental variables? Perhaps with gpsbabel.ini? > > The reason for this question is that I'd like to reliably extract data > from devices in parallel, and I'm expecting that setting the windows > environmental variable TMP on several concurrent threads will have > conflicts. > > Many thanks > Philip > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Gpsbabel-misc mailing list http://www.gpsbabel.org > Gps...@li... > To unsubscribe, change list options, or see archives, visit: > https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc > > > > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Gpsbabel-misc mailing list http://www.gpsbabel.org > Gps...@li... > To unsubscribe, change list options, or see archives, visit: > https://lists.sourceforge.net/lists/listinfo/gpsbabel-misc > > |