Im deploying a flask app on a remote server
When i run my lint and test locally on my macos I have no problem.
But when i run tar -cvf project.tar myfolder then ssh into my server and run tar -xf /tmp/project.tar -C /mydeployedfolder, i have hidden .py files that crashes my lint and test.
For example i have ._app.py file with content
Mac OS X 2?
ATTR
??com.apple.lastuseddate#PScom.macromates.selectionRange
This file doesnt appear on my initial foder on my macos (either in finder or if i do cat ._app.py in terminal) . I have tried to tar and untar locally on my mac but no such files appears either.
I have tried to run cmd+shift+. to have hidden files appear but it doesnt work
I have tried to run
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
And it is the same!
I also tried Forklift (a finder replacement where you can show hidden files) and i only have ._DS_Store no hidden py files
I also tried
dot_clean mypath
find . -type f -name '._*'
But it is the same
How can i do to avoid this or delete the hidden files?
Related
I am trying to make my python3 file executable from any location in the terminal (on mac os) so that instead of:
python3 myFile.py argv1 argv2 argv 3
Instead you type
myFile argv1 argv2 argv3
I can make the file executable via ./myFile but that's not really what I'm looking for and I can't make it executable from anywhere in the system.
Type which python3 to uncover where you have your python executable. In my case it is /usr/local/bin/python3 directory.
Your python file should contain a shebang referencing the executable as the first line in the file. So, for example:
#!/usr/local/bin/python3
Next, you must make sure that the file itself is executable.
Some files have different permissions (files can be read / write / execute and by different groups user / group / everyone). Execute on the terminal sudo chmod +x your_python_file.py.
Finally, you should add the directory where your file script is saved to your system $PATH.
In your terminal execute:
cd $HOME && mkdir bin
Put your python script in this bin directory. Then add the bin directory to your system $PATH by running:
export PATH="$HOME/bin:$PATH"
To make it executable without saying python first, put
#!/usr/bin/env python
as the first line and make the file executable.
To make it executable from any location, put the script in a directory that's in your $PATH environment variable.
I am trying to run a bash script from my Python code. I am calling the script in a subprocess like so:
preprocessed = subprocess.check_output([
'bash',
'../Paraphrase_Demo/models/processing_utils/preprocess_data_givenBPE.sh',
phrase, src_lang, tgt_lang, this_dir
])
Here is the script preprocess_data_givenBPE.sh:
#!/usr/bin/env bash
REMOTE_PATH=$4/processing_utils
SCRIPTS=$REMOTE_PATH/tiny-moses
TOKENIZER=$SCRIPTS/tokenizer.perl
DETOKENIZER=$SCRIPTS/detokenizer_v2.perl
CLEAN=$SCRIPTS/clean-corpus-n.perl
NORM_PUNC=$SCRIPTS/normalize-punctuation.perl
REM_NON_PRINT_CHAR=$SCRIPTS/remove-non-printing-char.perl
BPEROOT=$4/zhen/tools/subword-nmt/subword_nmt
text=$1
flan=$2
BPE=$4/$2$3/data/bpecodes
echo $text | perl $NORM_PUNC -l $flan | perl $REM_NON_PRINT_CHAR |
perl $TOKENIZER -a -l $flan -q | python3 $BPEROOT/apply_bpe.py -c $BPE | cat
When I run my Python program I get the following output:
Can't open perl script "C:/Users/Administrator/source/repos/Paraphrasing/Paraphrase_Demo/models/processing_utils/tiny-moses/normalize-punctuation.perl": No such file or directory
Can't open perl script "C:/Users/Administrator/source/repos/Paraphrasing/Paraphrase_Demo/models/processing_utils/tiny-moses/remove-non-printing-char.perl": No such file or directory
Can't open perl script "C:/Users/Administrator/source/repos/Paraphrasing/Paraphrase_Demo/models/processing_utils/tiny-moses/tokenizer.perl": No such file or directory
python3: can't open file 'C:/Users/Administrator/source/repos/Paraphrasing/Paraphrase_Demo/models/zhen/tools/subword-nmt/subword_nmt/apply_bpe.py': [Errno 2] No such file or directory
I have copy and pasted each of those paths into powershell and ls'd to verify that they are correct, but it still says it can't find them. What is going on here? This also happens if I run the bash script directly.
Edit: I've tried using backslashes in the path and received the same error. I also found this post: Bash: cannot execute a perl script using an absolute path?, so I tried using a relative path from the directory of my Bash script but it still says "No such file or directory."
After lots of debugging, I found the issue. While the paths I listed exist if I ls them in powershell, typing bash in powershell doesn't just open a bash shell, it actually changes the directory structure. I think this may be related to the Windows Subsystem for Linux, but the result is that C: changes to /mnt/c once inside the bash shell. Replacing this in all my paths, I was able to run my scripts.
I am working with a python package that I installed called bacpypes for communicating with building automation equipment, right in the very beginning going thru the pip install & git clone of the repository; the readthedocs calls out to:
Updating the INI File
Now that you know what these values are going to be, you can configure the BACnet portion of your workstation. Change into the samples directory that you checked out earlier, make a copy of the sample configuration file, and edit it for your site:
$ cd bacpypes/samples
$ cp BACpypes~.ini BACpypes.ini
The problem that I have (is not enough knowledge) is there isn't a sample configuration file that I can see in bacpypes/samples directory. Its only a .py files nothing with an .ini extension or name of BACpypes.ini
If I open up the samples directory in terminal and run cp BACpypes~.ini BACpypes.ini I get an error cp: cannot stat 'BACpypes~.ini': No such file or directory
Any tips help thank you...
There's a sample .ini in the documentation, a couple of paragraphs after the commands you copied. It looks like this
[BACpypes]
objectName: Betelgeuse
address: 192.168.1.2/24
objectIdentifier: 599
maxApduLengthAccepted: 1024
segmentationSupported: segmentedBoth
maxSegmentsAccepted: 1024
vendorIdentifier: 15
foreignPort: 0
foreignBBMD: 128.253.109.254
foreignTTL: 30
I'm not sure why you couldn't copy BACpypes~.ini. I know tilda could be expanded by your shell so you could try to escape it with
cp BACpypes\~.ini BACpypes.ini
Though I assume it isn't needed now that you have a default configuration file.
I want to install the app I found on a github page (https://github.com/googlei18n/fontview), how do I do it? I tried opening the 'build.py' file through mac terminal but it doesn't work, as well as pyton luncher- it freezes.
Kajas-MacBook-Pro:~ Kaja1$ cd fontview-master
Kajas-MacBook-Pro:fontview-master Kaja1$ cd src
Kajas-MacBook-Pro:src Kaja1$ cd fontview
Kajas-MacBook-Pro:fontview
Kaja1$ python2.7 build.py && ./build/FontView.app/Contents/MacOS/fontview
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'build.py': [Errno 2] No such file or directory
You are in the wrong directory. Change back to the folder fontview-master and run the command from there.
I am trying to use Python Fabric to copy a file from Windows to a debian system.
SOURCE: The Windows folder is C:\Users\UserN\Downloads contains the file test_celsius.out.
DESTINATION: The Debian folder is /mnt/Reado/RoTempValC.
I can move other files from the SOURCE to the DESTINATION using WinSCP. However, I need to use Fabric to move this particular file.
I can use Fabric to change into this directory and list its current contents:
ls /mnt/Reado/RoTempValC
Here is what I have tried - in a Fabric task named move() I have this
run('mv C:\Users\UserN\Downloads\test_celsius.out /mnt/Reado/RoTempValC')
Now, here is the output:
.
.
.
.
[10.10..] Executing task 'move'
[10.10..] run: mv C:\Users\UserN\Downloads\test_celsius.out /mnt/Reado/RoTempValC
[10.10..] out: mv: rename C:/Users/UserN/Downloads/test_celsius.out to /mnt/Reado/RoTempValC/test_celsius.out: No such file or directory
[10.10..] out:
Disconnecting from 10.10.. done.
Fatal error: run() received nonzero return code 1 while executing!
Requested: mv C:/Users/UserN/Downloads/test_celsius.out /mnt/Reado/RoTempValC
Executed: /bin/bash -l -c "mv C:/Users/UserN/Downloads/test_celsius.out /mnt/Reado/RoTempValC"
Aborting.
I am not sure why it is doing this. I can correctly list the contents of the directory in Debian by using the ls command above.
Is there a way to copy this file?
EDIT:
Additional Information:
I am running the above fab move command from the Windows command
prompt.
I opened the command prompt and typed cd Python27\SGTemp
since this is where the fabfile.py is located.
Then I ran fab move.
EDIT 2:
I replaced /mnt/Reado/RoTempVal by /mnt/Reado/RoTempValC/ but got the same output as above.
Try fabric.operations.put(*args, **kwargs):
put('C:\Users\UserN\Downloads\test_celsius.out', '/mnt/Reado/RoTempValC')