Major readme update, couple of backslashes removed

In Readme.md:

- Updated the readme to include instructions for Windows users.
- Added instructions for OAuth2 (copied from inside the get_secret.py with
some modifications).
- Added a warning for possible future deprecation of the password based
authentication.

In shreddit.py:

- removed \ which was used for wrapping in the next line. Used paranthesis
  and '''multiline string''' where needed.

In requirements.txt:

- changed praw==3.3.0 to 3.5.0
pull/58/head
dragsubil 9 years ago
parent 3fcbfb101a
commit ef0e933a7b

@ -7,26 +7,36 @@ YAML Upgrade
**Note! Important! The latest version uses YAML format over the old simpleconfigparser! **Note! Important! The latest version uses YAML format over the old simpleconfigparser!
This means you'll have to migrate your config file to yaml!** This means you'll have to migrate your config file to yaml!**
User Login deprecation
--------------------
Reddit intends to disable username-password based authentication to access its APIs in the near future. You can specify your username and password in the `shreddit.yml` or the `praw.ini` to make it work **FOR NOW**. But consider looking at the [OAuth2 instructions](#oauth2-instructions) if you intend to use this program in the future.
Description Description
----------- -----------
Shreddit is a Python command line program which will take a user's post history on the website Reddit (http://reddit.com) and after having the user edit a config file will systematically go through the user's history deleting one post/submission at a time until only those whitelisted remain. Shreddit is a Python command line program which will take a user's post history on the website [Reddit](http://reddit.com) and after having the user edit a config file will systematically go through the user's history deleting one post/submission at a time until only those whitelisted remain.
Note: When it became known that post edits were *not* saved but post deletions *were* saved code was added to edit your post prior to deletion. In fact you can actually turn off deletion all together and just have lorem ipsum (or a message about Shreddit) but this will increase how long it takes the script to run as it will be going over all of your messages every run!
**Note:** When it became known that post edits were *not* saved but post deletions *were* saved, code was added to edit your post prior to deletion. In fact you can actually turn off deletion all together and just have lorem ipsum (or a message about Shreddit) but this will increase how long it takes the script to run as it will be going over all of your messages every run!
Basically it lets you maintain your normal reddit account while having your history scrubbed after a certain amount of time. Basically it lets you maintain your normal reddit account while having your history scrubbed after a certain amount of time.
Installation Installation ([Click here for Windows instructions](#for-windows-users))
----------- -----------
The way I personally install Shreddit is via a handy tool called `virtualenv` which may come with your package manager or may be a part of your Python package in your distro (have a search if you can't find it). Both Python 2 and 3 are supported. The way I personally install Shreddit is via a handy tool called `virtualenv` which may come with your package manager or may be a part of your Python package in your distro (have a search if you can't find it). Both Python 2 and 3 are supported.
1. Clone the repository 1. Clone the repository
2. Enter the repository's directory and run `virtualenv .` (this creates a virtual environment) 2. Enter the repository's directory and run `virtualenv .` (this creates a virtual environment)
3. Run the following command, you must run this *every time* you wish to run the script `source ./bin/activate` 3. Run the following command, you must run this *every time* you wish to run the script `source ./bin/activate`.
4. This installs the required modules locally to your Shreddit virtual environment `pip install -r requirements.txt` 4. This installs the required modules locally to your Shreddit virtual environment `pip install -r requirements.txt`.
5. Copy `shreddit.cfg.example` to something else and edit it to your liking. 5. Copy `shreddit.yml.example` to something else and edit it to your liking.
6. Run `python shreddit.py -c YOUR_CONFIG_FILE.cfg`. - Make sure you specify your username and password in the file.
- See the [OAuth2 instructions](#oauth2-instructions) if you don't want to use username-password based authentication.
6. Run `python shreddit.py -c YOUR_CONFIG_FILE.yml`.
Alternatively try to run `./install.sh` and it will attempt to do it all for you. Alternatively try to run `./install.sh` and it will attempt to do it all for you.
Notes: Notes:
- The script *does* work with Python versions 2 and 3 but people often get in a mess with pip versions, python versions and virtulenv versions. Make sure that your Python/pip/virtualenv are all the same version. If you ran the above code it *should* work as stated. - The script *does* work with Python versions 2 and 3 but people often get in a mess with pip versions, python versions and virtulenv versions. Make sure that your Python/pip/virtualenv are all the same version. If you ran the above code it *should* work as stated.
@ -49,6 +59,34 @@ Cron examples
If for some reason you get an error saying `source: not found` in your logs, change `source` to `.`. The source command would become `. bin/activate`. This is caused by your cron jobs running in shell, not bash, and the source command is a dot. If for some reason you get an error saying `source: not found` in your logs, change `source` to `.`. The source command would become `. bin/activate`. This is caused by your cron jobs running in shell, not bash, and the source command is a dot.
For Windows users
-----------------
1. Make sure you have python installed. [Click here for the Python download page](https://www.python.org/downloads/).
- **Note:** Install either `python 2.x` or `python 3.x`, not both.
2. Clone the repository (or download and extract the [zip file](https://github.com/dragsubil/Shreddit/archive/master.zip))
3. Open command prompt and type `cd <path to the Shreddit folder>`
4. Type `pip install -r requirements.txt` to download and install the required additional modules.
5. Open the `shreddit.yml.example` and edit it to your liking and rename the file to `your-config-filename.yml`.
- Make sure you specify your username and password in the file.
- See the [OAuth2 instructions](#oauth2-instructions) if you don't want to use username-password based authentication.
6. Type `python shreddit.py -c your-config-filename.yml` to run the program.
OAuth2 Instructions
-------------------
1. Visit: https://www.reddit.com/prefs/apps
2. Click on 'Create app'.
- Fill in the name and select the 'script' option
- Under "redirect uri" put http://127.0.0.1:65010
3. Copy from or rename `praw.ini.example` to `praw.ini` and open it. Enter the values from the Reddit page.
- oauth\_client\_id = { The ID displayed next to the icon thingy (under "personal use script") }
- oauth\_client\_secret = { The secret }
- oauth\_redirect\_uri = http://127.0.0.1:65010
- Save the file.
4. Run `python get_secret.py` in the command prompt.
5. Your browser will open to a page on Reddit listing requested permissions.
6. Click 'Allow'.
Caveats Caveats
----------- -----------
- Only your previous 1,000 comments are accessible on Reddit. So good luck deleting the others. There may be ways to hack around this via iterating using sorting by top/best/controversial/new but for now I am unsure. I believe it best to set the script settings and run it as a cron job and then it won't be a problem unless you post *a lot*. I do, however, think that it may be a caching issue and perhaps after a certain time period your post history would, once again, become available as a block of 1,000. So you needn't despair yet! - Only your previous 1,000 comments are accessible on Reddit. So good luck deleting the others. There may be ways to hack around this via iterating using sorting by top/best/controversial/new but for now I am unsure. I believe it best to set the script settings and run it as a cron job and then it won't be a problem unless you post *a lot*. I do, however, think that it may be a caching issue and perhaps after a certain time period your post history would, once again, become available as a block of 1,000. So you needn't despair yet!

@ -1,6 +1,6 @@
backports-abc==0.4 backports-abc==0.4
decorator==4.0.6 decorator==4.0.6
praw==3.3.0 praw==3.5.0
PyYAML==3.11 PyYAML==3.11
requests==2.8.1 requests==2.8.1
six==1.10.0 six==1.10.0

@ -11,8 +11,8 @@ import praw
from re import sub from re import sub
from random import shuffle, randint from random import shuffle, randint
from datetime import datetime, timedelta from datetime import datetime, timedelta
from praw.errors import InvalidUser, InvalidUserPass, RateLimitExceeded, \ from praw.errors import (InvalidUser, InvalidUserPass, RateLimitExceeded,
HTTPException, OAuthAppRequired HTTPException, OAuthAppRequired)
from praw.objects import Comment, Submission from praw.objects import Comment, Submission
logging.basicConfig(stream=sys.stdout) logging.basicConfig(stream=sys.stdout)
@ -24,6 +24,7 @@ try:
except ImportError: except ImportError:
def get_sentence(): def get_sentence():
return '''I have been Shreddited for privacy!''' return '''I have been Shreddited for privacy!'''
os_wordlist = '/usr/share/dict/words' os_wordlist = '/usr/share/dict/words'
if os.name == 'posix' and os.path.isfile(os_wordlist): if os.name == 'posix' and os.path.isfile(os_wordlist):
# Generate a random string of words from our system's dictionary # Generate a random string of words from our system's dictionary
@ -69,8 +70,8 @@ try:
r.refresh_access_information() r.refresh_access_information()
log.debug("Logged in with OAuth.") log.debug("Logged in with OAuth.")
except (HTTPException, OAuthAppRequired) as e: except (HTTPException, OAuthAppRequired) as e:
log.warning("You should migrate to OAuth2 using get_secret.py before \ log.warning('''You should migrate to OAuth2 using get_secret.py before
Reddit disables this login method.") Reddit disables this login method.''')
try: try:
try: try:
r.login(config['username'], config['password']) r.login(config['username'], config['password'])

@ -2,8 +2,8 @@
# Login details for Reddit. Fill out if you don't wish # Login details for Reddit. Fill out if you don't wish
# to be prompted for a login every time you run Shreddit. # to be prompted for a login every time you run Shreddit.
### NOTE: This may be deprecated as you can specify in praw.ini instead ### NOTE: This may be deprecated as you can specify in praw.ini instead
username: null username:
password: null password:
# How many hours of comments you want to keep # How many hours of comments you want to keep
# 24 hours in a day, # 24 hours in a day,

Loading…
Cancel
Save