File extracted from ZIP not recognized until re-save - angularjs

Q: Why would re-saving a file be different vs a direct extraction from a zip file? Particularly on Windows?
Context
I have an angular application that prepares a text file for import into a commercial machine. For user convenience, we provide the file inside a zip file so that the required folder structure can be provided to the user. They write this file to a USB drive and use that to import into the machine.
Problem
If the downloaded zip file is extracted directly onto the USB (to get the file and the required folder structure), the machine cannot recognize the embedded text file.
Troubleshooting
If I open the file in any text editor, add a space, delete the space, and re-save the file on the USB, then the machine will recognize the file. Alternatively, if I extract the zip onto the local file system, then copy the folder structure from the local file system to the USB, then the machine also will recognize it.
If I switch to Linux, then a 'write out' from nano will fix the file. If I use the touch command on the file, the problem remains.
Suspecting a whitespace/line-ending issue, I've tried several diff tools which reveal no apparent differences:
$ diff original.txt resaved.txt (Linux)
$ vbindiff original.txt resaved.txt (Linux)
> fc /b original.txt resaved.txt (Windows 7)
Other info:
Angular version: 5.2.10
Zip Utility in angular: JSZip 3.1.5
Unzip Utils: 7-Zip and Native Windows Explorer extract
JSZip code:
const zip = new JSZip();
zip.folder('FolderA/FolderB/FolderC').file('FILE.TXT', new File([contentString], 'TEMP.TXT', { type: 'text/plain' }));
zip.generateAsync({ type: 'blob' })
.then(function (content) {
saveAs(content, 'ZipFile.ZIP');
});
At this point, I'm out of ideas. Hoping someone here may have some insight into this odd behavior.

TL;DR: Check the file attributes (e.g. Archive, Read-Only, Hidden, System, etc).
Our system was specifically looking for the Archive bit and modifying the file in any way set this bit.
This was an ugly one to ferret out, but chatting with our embedded systems programmer for a bit led to the answer.
Our machine was specifically searching for the archive bit (Windows file attribute) when it was searching for files to import. This bit is a relic from Windows NTFS and is near obsolete. For all intents and purposes it is a dirty flag used to point out files that should be archived/backed up in the next backup run. There are much better ways to do this, so it has fallen out of style.
However, for whatever reason, our system is searching only for files with that bit set. That's why opening/copying/moving the file would fix the problem, because altering it in any way set this archive bit (dirty flag).
If you want to learn more about it, see here and here.
So, the moral of the story is to check these file attributes if you have a similar issue.
We are using the Harmony USB driver from Microchip, so this may be a nuance of that tool (or maybe just an artifact from one of the online examples).
You can see it this using the file properties in Windows Explorer or with the > attrib <file> command in Windows command prompt.
To fix:
Windows: You can set the value from the command prompt using > attrib +a <file> or remove it using > attrib -a <file>.
If using node.js on a Windows host, you can use the winattr library from NPM to manipulate these attributes.
Linux: You can use $ getfattr and $ setfattr to set the bit (see here and here).
Note: the answers I linked say to use $ setfattr -h -v 0x00000020 -n system.ntfs_attrib_be <target-file> but I got an operation not supported when I tried to do the same. I ended up using the java solution, but when I inspected the file afterward, it seemed the equivalent command would have been $ setfattr -n user.DOSATTRIB -v 0sMHgyMAA= <target-file>. Your mileage may vary but I offer it in case it helps anyone.
Java: You can also use Java from any system.

Related

adb pull file in Arabic Language(UTF-8) encoding

i tried to pull it using
adb pull /sdcard/جهات الإتصال.vcf D:/
but when i write it in CMD it's shows as non-understood language
any ideas please
This question has deleted answer by #sachin-das stating that adb.exe from andriod platform tools handles Japanese filenames properly.
I've rechecked that platform-tools-latest-windows.zip\platform-tools\adb.exe version 1.0.39 from Andriod Platform Tools handles Russian filenames correctly too.
My old adb.exe v1.0.32 was corrupting filenames. While adb.exe of the same v1.0.32 from #sachin-das's google drive didn't.
So I guess there are different builds of adb of the same version roaming in the wild.

TortoiseSVN batch file output info

I am trying to do the equivalent of the following Linux command with a Windows batch file and TortoiseSVN.
svn info > info.txt
I have tried the following with no luck:
start /wait "" "c:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:info >> %CD%\info.txt
I am running Windows with TortoiseSVN v1.6.16 so I don't have access to the command line tools.
Note: We were encountering issues with the newer version of TortoiseSVN so we went back to 1.6 until issues are resolved with a newer version and the company upgrades the server to that version.
Your construction didn't work, doesn't work and will never work due to zero-bits of trueness:
start (with and without /wait) have sense in bat-file only if you have more than one bat-process starting from this bat (compare with call), for called GUI it doesn't differ from direct using program-name
TortoiseProc is GUI-app after all, it emits nothing to stdout
Info was and is unknown command for TortoiseProc, thus you'll get only GUI-window "About"
:about Shows the about dialog. This is also shown if no command is
given
In addition to correct suggestion "Update to at least 1.8 on client and have CLI-tools" you can consider following solutions:
Install from unrelated to TortoiseSVN sources pure CLI SVN-client (also 1.6.* - from WanDisco will be good choice) at the same as TSVN or another location (I done it at the times of 1.6)
Study and use subwcrev (it was part of TortoiseSVN even in 1.6, AFAICR) and emulate some part of svn info in subwcrev's template-file with correct keywords

Install Packages (for dummies)

I know there's a lot of information on here about installing python packages, but I'm quite new to python and I think I need a more "for dummies" level of help.
I was trying to install openpyxl for which as far as I can tell I need easy_install, for which, as far as I can tell, I need setuptools. I tried running the code provided here https://pypi.python.org/pypi/setuptools which is supposed to download and install setuptools (and according to some sites, easy_install aswell?) - it runs successfully, but help(modules) doesn't show setuptools or easy_install as modules, I have no idea whats installed and what isn't, or how I'm supposed to install any of it!
Essentially I'm very confused, very frustrated and really need someone to talk me through (in idiot-speak) what I'm supposed to do.
Thankyou!
We all start somewhere, I was there two weeks ago.
I'll assume you're using Python2. I believe Distribute and Pip are recommended for Python3 (which I will be using as examples). I will also assume you are on Windows.
First, python needs to be registered to Path. To check if this has been done automatically, open a command prompt (start -> programs -> accessories), and type 'python', then enter. If it returns the version number, etc, skip down a bit. If it throws an error, you need to add Python to Path.
Adding Python to Path
To add Python to Path on a Windows computer, go to:
Control Panel -> System -> Advanced Settings -> Environment Settings -> System Variables
Scroll down to select path, then click edit. Copy the entire line to a text document, and add your install directory for Python.exe (and the scripts folder) using ';' as a delimiter between different directories. Copy this back to Path and save. (Additionally close your command prompt window to reset it.)
For my Windows 7 machine, I added:
;C:\Python33;C:\Python33\scripts;
Take care when editing this file. There are many videos out there describing this in detail if you feel unsure about changing this.
Installing Modules (Such as setup_tools)
Once Python is registered in the Path file, download and unzip setup_tools to a folder within your Python install directory called 'modules'. I use ExtractNow to unzip, as it will unzip twice (as required) automatically.
Open a command prompt window again, and direct it to change directories by typing
cd [directory for module you want to install]
On my computer, this would be
cd C:\Python33\modules\distribute-0.6.40
Again, I use distribute, rather than setup_tools as it sounds like you need would for Python2. Simply use the appropriate directory. Press enter to change the directory.
Once you've entered this and it shows a changed directory, type:
python setup.py install
This indicates that you want to use the program python to use the setup.py file in the specified folder to install the module. This should be successful, and will write many lines of code.
If you want to install other modules, you would install them in a similar way. Python would automatically use setup_tools on your computer to finish each install.
Remember to import at the start of your script when using them to code:
import [module]
Happy Programming!

DocBlox error: The XSL writer was unable to find your XSLTProcessor

I am using WAMP on my local machine and I'm trying to use docblox to generate documentation for a project.
When i try to run the docblox command in my command prompt for a file that has the necessary comments, I get the error message.
C:\wamp\www\wm-ppclps>docblox run -f wm-ppclps.php -t documentation
DocBlox version 0.18.1
Starting transformation of files (this could take a while depending upon the size of your project)
ERROR: The XSL writer was unable to find your XSLTProcessor; please check if you
have installed the PHP XSL extension
I have no idea why this is error message is appearing. The command creates the documentation folder, parses the source code and it produces the structure.xml file. It just won't transform the structure into an HTML file or any other readable file.
I added the PHP install directory to my system path, I installed PEAR system wide, added PEAR install directory to my system path, installed DocBlox using the docblox pear channel, I have the necessary environment variables setup. I uncommented the php.ini line to enable the php_xsl.dll extension for WAMP and restarted WAMP. When I view the phpinfo, i see that the XSL extension is enabled (XSL version 1.1.23, compiled against libxml version 2.6.32, EXSLT enabled).
Does anyone have any idea why this is happening, has come across this problem or can point me in the right direction for an answer?
The error that you are receiving means that php does not recognize the xsl extension.
Php has got a separate ini file for CLI and web; and I presume that you have enabled the xsl extension for apache only.
You can verify this by executing php -i in your command prompt and check if the xsl extension is enabled there. If not then add your dll to the right config for your WAMP.

vim cannot connect to cscope database

I have opensuse 11.4 installed. Vim is version 7. Now I normally use it to browse the linux kernel source. So I generated the cscope database inside a directory within my home folder i.e. /home/aijazbaig1/cscope_DB/ and I got 3 files viz. cscope.out, cscope.po.out and cscope.in.out besides the cscope.files file which contains a list of all the relevant files which I want to search.
Additionally I have added the following to my .bashrc:
CSCOPE_DB=/home/aijazbaig1/cscope_DB/cscope.out
export CSCOPE_DB
But when I do a :cscope show from within vim it says there are no connections. Can anyone please let me know what is going wrong.
Keen to hear from you,
This is mentioned in the comments above, but I want to make sure it's preserved in an answer.
The issue that came up for me was that vim didn't know where to look for the cscope database. When I added
cs add $CSCOPE_DB
to my .vimrc. Everything came out fine.
I figure since I've made the visit, I would try responding.
I was getting this error when searching using ctrl-space s (or any search for that matter):
E567: no cscope connections
I finally found the full solution at http://cscope.sourceforge.net/cscope_vim_tutorial.html, Step 11.
The idea is that you create a list of source files to be included in the view of cscope, generate the cscope.out in the same location, and update the export path accordingly:
find /my/project/dir -name '*.c' -o -name '*.h' > /foo/cscope.files
cscope -R -b (this may take a while depending on the size of your source)
export CSCOPE_DB=/foo/cscope.out (put this in your .bashrc/.zshrc/other-starting-script if you don't want to repeat this every time you log into the terminal)
You need to add a "cscope connection", like this in vim:
:cscope add $PATH_TO_CSCOPE.out
See :help cs for more examples.
Here's how I explore linux kernel source using cscope:
I use vim as my editor.
While standing inside the kernel source root directory, run cscope in interactive mode while recursively going through subdirectories during search for source files:
cscope -R
When run for the first time, it will generate the database file with the name: cscope.out inside the current directory. Any subsequent runs will use the already generated database.
Search for anything or any file and open it.
Set cscope tags in vim to make the :tag and CTRL-] commands search through cscope first and then ctags' tags:
:set cscopetag
Set cscope database inside current VIM session:
:cs add cscope.out
Now you can use CTRL-] and CTRL-t as you would do in ctags to navigate around! :)
I have the same issue on my PC. For now, to solve the issue:
On terminal execute: which is cscope
Open .vimrc file to edit: set csprg=/usr/bin/cscope
I ran into a similar problem with no cscope connections on ubuntu 18.04, then I discovered my .vimrc file does not load the CSCOPE_DB variable. Looked a little around and found a solution.
You can just copy this directly in to your .vimrc file.
Part of the code loads your cscope file from your directory. The keybinds are just a nice bonus.
Hope this helps.

Resources