shell

Escaping a Linux path in Python without quotes, the correct way

Escaping a Linux path in Python without quotes, the correct way Question: I’m seeing a large amount of answers on here to this question that are blatantly incorrect or are partially correct but don’t account for any variances outside of a small scope. here is my path: "/home/user/text/Chapter 1-100" In bash/zsh I can hit tab …

Total answers: 1

nothing happens after running python manage.py shell < script.py

nothing happens after running python manage.py shell < script.py Question: This is my first time trying to run a script. I’m trying to hash previously stored plain text in my db. Anyway I created script.py file in my project folder it doesn’t seem to do anything what am I missing? The command I’m running in …

Total answers: 1

How to run .sh file from console

How to run .sh file from console Question: I would like to know why I can not run the .sh file via ./launch.sh please have a look at the below posted screen-shot image Asked By: LetsamrIt || Source Answers: You need to mark it as an executable program with chmod +x launch.sh, or alternatively execute …

Total answers: 3

Python reading text file every second line skipped

Python reading text file every second line skipped Question: I am processing a shell script in Python. My first step is to comb through the file and save only the important lines in a list (of strings). However, I have isolated a problem where every second line is ignored. Why is the second, fourth, etc. …

Total answers: 1

when is it "safe" to mix path separators in Python strings representing Windows paths?

when is it "safe" to mix path separators in Python strings representing Windows paths? Question: This minimal example: (Running in PyCharm debugger) import os from os.path import join import subprocess src_path = r’C:/TEMP/source’ dest_path = r’C:/TEMP/dest’ if __name__ == "__main__": for root, _, files in os.walk(src_path): for name in files: src_file_path = join(root, name) rel_dest_file_path …

Total answers: 1

Extract a value from an array of data

Extract a value from an array of data Question: I get such an array of data [U8EUGGG1C32144101336_gulu, V5EUHHG1P12100100418_89011337751, V5EUHHG1P22111000028_89011337751] How I can extract only this value "89011337751" and write it to a variable ? Is it possible to do it with the bash, powershell or other scripts? Asked By: Vitaliy Kuzmenko || Source Answers: This …

Total answers: 1

Run short python code directly on snakemake

Run short python code directly on snakemake Question: I have a snakemake pipeline where I need to do a small step of processing the data (applying a rolling average to a dataframe). I would like to write something like this: rule average_df: input: # script = , df_raw = "{sample}_raw.csv" params: window = 83 output: …

Total answers: 2

sed and rev shell command into Python script

sed and rev shell command into Python script Question: There is a shell command, I am trying to convert the logic into python. But I don’t know what to do, I need some help with that. shell command is this : cd ../../../tests/src/main/test ls find . -name ‘*.vrlp’ | while read FILENAME do TEST_CASE=`echo $FILENAME …

Total answers: 1

Shell find logic into Python script

Shell find logic into Python script Question: cd db/test/vs ls find . -name ‘*.vrlp’ | while read FILENAME do TEST_CASE=`echo $FILENAME | sed s/"./"//g | sed s/".vrlp"//g | rev | cut -f1 -d"/" | rev` CLASS=`echo $FILENAME | sed s/"./"//g | sed s/"/$TEST_CASE"//g | sed s/".vrlp"//g` done There are a lot of class files (FILENAME) …

Total answers: 1