unix

Ansible: best practice for maintaining list of sudoers

Ansible: best practice for maintaining list of sudoers Question: In the documentation, there is an example of using the lineinfile module to edit /etc/sudoers. – lineinfile: “dest=/etc/sudoers state=present regexp=’^%wheel’ line=’%wheel ALL=(ALL) NOPASSWD: ALL'” Feels a bit hackish. I assumed there would be something in the user module to handle this but there doesn’t appear to …

Total answers: 2

How can I write find and exec command in python

How can I write find and exec command in python Question: I have a shell script that does find /tmp/test/* -name “*.json” -exec python /python/path {} ; it looks for all the JSON files in specific directories and executes the OTHER python script that I have.. How can I do this python scripting? Asked By: …

Total answers: 5

How to prevent BrokenPipeError when doing a flush in Python?

How to prevent BrokenPipeError when doing a flush in Python? Question: Question: Is there a way to use flush=True for the print() function without getting the BrokenPipeError? I have a script pipe.py: for i in range(4000): print(i) I call it like this from a Unix command line: python3 pipe.py | head -n3000 And it returns: …

Total answers: 8

Resource u'tokenizers/punkt/english.pickle' not found

Resource u'tokenizers/punkt/english.pickle' not found Question: My Code: import nltk.data tokenizer = nltk.data.load(‘nltk:tokenizers/punkt/english.pickle’) ERROR Message: [ec2-user@ip-172-31-31-31 sentiment]$ python mapper_local_v1.0.py Traceback (most recent call last): File “mapper_local_v1.0.py”, line 16, in <module> tokenizer = nltk.data.load(‘nltk:tokenizers/punkt/english.pickle’) File “/usr/lib/python2.6/site-packages/nltk/data.py”, line 774, in load opened_resource = _open(resource_url) File “/usr/lib/python2.6/site-packages/nltk/data.py”, line 888, in _open return find(path_, path + [”]).open() File “/usr/lib/python2.6/site-packages/nltk/data.py”, line …

Total answers: 18

pyvenv-3.4 returned non-zero exit status 1

pyvenv-3.4 returned non-zero exit status 1 Question: I’m in Kubuntu 14.04 , I want to create a virtualenv with python3.4. I did with python2.7 before in other folder. But when I try: pyvenv-3.4 venv I’ve got: Error: Command ‘[‘/home/fmr/projects/ave/venv/bin/python3.4’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1 Asked By: kahonmlg || Source Answers: I …

Total answers: 19

OSError – Errno 13 Permission denied

OSError – Errno 13 Permission denied Question: I am trying to upload image through admin page, but it keeps saying: [Errno 13] Permission denied: ‘/path/to/my/site/media/userfolder/2014/05/26’ the folders userfolder/2014/05/26 are created dynamically while uploading. In Traceback, i found that the error is occuring during this command: In /usr/lib64/python2.6/os.py Line 157. while calling mkdir(name, mode) meaning, it …

Total answers: 8

Split large text file(around 50GB) into multiple files

Split large text file(around 50GB) into multiple files Question: I would like to split a large text file around size of 50GB into multiple files. Data in the files are like this-[x= any integer between 0-9] xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx …………… …………… There might be few billions of lines in the file and i would …

Total answers: 6

How to get the exit status set in a shell script in Python

How to get the exit status set in a shell script in Python Question: I want to get the exit status set in a shell script which has been called from Python. The code is as below Python script result = os.system("./compile_cmd.sh") print result File compile_cmd.sh javac @source.txt # I do some code here to …

Total answers: 3