-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code refactored to work in python3.6 #16
Code refactored to work in python3.6 #16
Conversation
Does this work on your machine? Have you checked it properly? When i try to run it on my machine, i get error when tried to get tweets of any user.
|
I've solved the issue with the hashtag search that you pointed out, but I've encountered a new one. Tweepy is giving me a 429, so we need to do some math to figure out how to limit the number of requests that we're sending to the Twitter API to a reasonable number. I may open up a new issue if a solution doesn't become totally apparent with a little searching through the API documentation. |
I think all issues above have been solved and the rate limiting has been implemented. The fixed version is #17. |
I checked your PR. It does not seem to be working on my machine. I get error while getting the twitter data. The options are printing twice and i get error when i select one of the options. May be i am not executing the file as it should be executed. I am doing python3 twweet-cli.py. I will provide the error log below. Please check it error log |
You'll need to hard code your account credentials into cfg at the top of twweet-cli.py to get this to work, status code 400 means bad authorization. I figured that we weren't going to rely on the SQL db to provide credentials anymore as discussed in #13 so I commented out that part of the code. Sorry, that was kind of my bad for not mentioning it in the pull request or my last comment. I know that the feature worked because I generated #100DaysofCode.csv and CruiseDeviceTweets.csv with it, here's the tests I did on the broken features: |
I think it would be good if it this is maintained as a new branch. Like one branchfor python 2.7 and one for python 3.6 |
Yeah, I think you're right. Sorry I haven't updated this in a while, things got away from me with my other projects. I'm currently working on a upgrade for this branch that allows details different accounts to be stored in a JSON file which I hope to upgrade to a pkl file using the pickle package for python for encryption so that account details aren't stored in plain text in a file. I'll close these pull requests once it's finished and open a new one. |
But your code has to be made to python 2.7 as both versions are released. And it should also be released in PyPi |
It should be relatively easy to migrate between the two different versions, really just a matter of changing most input() calls to raw_input() calls. I can't say I've ever done python packaging before so trying to get it released in PyPi would be pretty new for me. |
The code is not just about input but there is syntax changes in python 3.6 |
Actually the way I refactored things, the only change should be the inputs. I over parenthized some print statements and added some .format calls that will work in both python 2.7 and python 3.6 to minimize the effort of going back and forth in the future. There really weren't any other compiling issues. |
@ediamondscience Please update your fork with the master fork and send the pr to the new branch python-3.6. Before sending the pr verify all the functionalities are working, so the project should not break. Last time i didn't merge your pr because it was printing the options two times where it must print the option one time (you can refer the screenshots above). Even some of the options were not working, i don't know the exact reasons behind it. |
@CruiseDevice I've got a version that I've maintained for some time on my fork, under the json+multiaccount branch. It's got a drastically different method for credential input, making it somewhat easier to get many sets of credentials entered at once. It has the user enter their credentials through a 4 line text file in an input directory for each account. It then reads those files once the program starts and builds a json file that contains the credentials for every account while checking for duplicate accounts. I'd be more than happy to create a pull request with the new branch here for that code if you'd like, but I don't think I'll be porting the current master branch over to python3.6 again as I really don't see what good that would do anyone considering how obsolete it would feel compared to my current branch. Have a look at that one and let me know what you want me to do. For the last pull request, I checked and made sure that all the functions worked the same as they did for the python2.7 build. If things crashed for you it might be down to having issues going between the two versions of python, or not having your credentials in the right place (your code 400 error). As for the UI duplication issues that you're referencing, they were a part of your code at the time, I just didn't bother to fix them because I wasn't here to work on UI, I was here to port the program to a newer version of python and add features to make it easier to use. It ended up being an extra main() call as I remember from fixing it on my latest branch. |
I think you removd the edit option from the program in ur fork. Y that change I didn't understand. Edit is needed ryt???. Or we wud have to edit the directly. Please check that in that branch json+multiaccount |
Yes, as I previously stated in this comment thread I replaced it with something I found infinitely easier to use. Instead of having a user manually type out their keys, it was easier to copy and paste into a text file and place it into an /input/ directory within the same directory as twweet-cli. The directory is checked each time the program is run and any text files that don't already have an entry in the accts.json file that the program generates are added in. Pretty sure that's all in the initaccs() function definition. There is also a set of instructions that display when you try running it for the first time or when you get bad authorization errors that explains all this as well. Have you tried running the program from my branch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make changes as per the comments and update this according to the master branch
@@ -47,7 +47,7 @@ def get_all_tweets(screen_name): | |||
# update the id of the oldest tweet less one | |||
oldest = alltweets[-1].id - 1 | |||
|
|||
print "...%s tweets downloaded so far"%(len(alltweets)) | |||
print("...%s tweets downloaded so far".format(len(alltweets))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print("...%s tweets downloaded so far".format(len(alltweets)))
--> print("... {} tweets downloaded so far".format(len(alltweets)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in line 99, with open('%s.csv'%hash_tag, 'wb') as f:
--> with open('%s.csv'%hash_tag, 'w') as f:
And in line 56, with open('%s_tweets.csv' % screen_name,'wb') as f:
--> with open('%s_tweets.csv' % screen_name,'w') as f:
@nithinswarrier See #17, this is an older pull request than that one and it has the updated code. |
As discussed in #15. I've tested tweeting, viewing trending hashtags, and viewing my timeline, but I haven't gone through all of the other features to make sure they aren't inexplicably broken. I'd suggest keeping the old master as a legacy branch just in case.