Skip to content
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

How to use habitica-todo #8

Open
vj88 opened this issue Jan 6, 2017 · 16 comments
Open

How to use habitica-todo #8

vj88 opened this issue Jan 6, 2017 · 16 comments

Comments

@vj88
Copy link

vj88 commented Jan 6, 2017

Hi,

I read the readme and all it says is to install pip install habitica and pip install pytodoist. Is that all I have to do to get this running? I assume not. But I can't seem to get it working.

Thanks

@Zwirbel1
Copy link

Hi,

I have exactly the same problem. It would be nice if you could describe (shortly) how to get this running.

Best regards,
Christoph

@ftlbiped
Copy link

Likewise. I'm not quite python savvy enough to get this working just from sorting through the source code, but this seems to have several advantages over the NodeJS solution so I'd like to get it working if I can. Even a few pointers in the right direction would be helpful.

@eringiglio
Copy link
Owner

Oof! Just saw this. Right now, actually, what you need to do to install it is.... well, honestly, you could probably just download and unzip the repository here and run the python program oneWaySync from the folder. I keep meaning to make this a pip folder but haven't actually devoted a lot of time to working through it.

If you folks would like to work through bits with me, I'd love the help. Is there anything I could comment better to make it more clear?

I have GOT to update the readme documentation and actually put this thing into a pip install package. I'm so sorry, I didn't actually realize folks were trying to use this till now!

@NonSparkly
Copy link

I'm having the same issues. Habitica looks amazing due to the way it can handle long term goals, challenges and habit-mapping, but Todoist is vastly superior at task-managing (at least if you like me have used that every day for the past 2 years).

Can't even understand how I'm supposed to get this to work. I have no coding skills what so ever, I just want to get them todoist and Habitica to talk to each other and have no idea how to do it.

My question is also whether or not I can get this to run automatically through my browser or if I need to have an active machine that does the sync? Because I'm less interested if I have to have a machine running at all hours of the day just to act like a bridge.

@ftlbiped
Copy link

@eringiglio If (as the docstring suggests) oneWaySync.py is meant to replicate the one way todoist->habitica sync of todoist-habitrpg, which file manages the other direction? I was trying to run basicSync.py and running into an error - I can put more detail in its own github issue if that's unexpected behavior, but perhaps basicSync.py is not meant to be run directly after all?

Happy to help work through bits as time permits.

@eringiglio
Copy link
Owner

@NonSparkly Currently, as I'm running this, it can be run from any machine and should not require you to keep a particular machine running it full-time. I don't, however, think you can run it on a browser--like habitrpg-todo, it will require running on a command line in Mac or Linux. (It should work fine in Cygwin if you use that on Windows.) I don't have the coding skills or experience right now to host a browser-based version, but if that's something you really really want I would be happy to help you figure out how to do it.

Now, it's not set up to automatically run, and you currently don't need to keep your history file on hand for it to work--it just makes things a little faster. I typically run it by basically telling the program to run in my command line every few hours manually, but you could have it automatically run by using a crontab command in a command line from a particular machine if you wanted to.

Does that help at all? I can explain in more detail about those terms if you're not familiar with them--not sure what your experience level is.

@eringiglio
Copy link
Owner

@dkassler Oh man, I'd love the help! One problem I think you're running into with this is that as I kind of forgot that other people might like to play with this code or use it too, I also stopped using best practices for naming files as I switched things up and refigured things. I really need to comment this code a little bit better, but I think I've done some helpful reorganizations with this latest commit that should make things a little less.... uh, ridiculous.

More on each script in a minute; I'm going to write out a few additional comments with that.

@eringiglio
Copy link
Owner

For the perplexed, a guide to what is in the various python scripts! I'm erring on the side of exhaustive mostly so that this should be understandable to anyone no matter what their experience level, so I apologize if any of this comes off as condescending; it's not meant to! I am entirely self-taught as a coder, so I know how frustrating it is to run into things that are not well explained as a novice. (It's also totally possible I am missing things in my python knowledge about how one might play with or use this script, incidentally; if you think of better ways to do things by all means please tell me!) Okay.

Here are the functional scripts now hanging out in the habiticaTodo folder:
castSpells.py - This exists because in my party, I am one of our very few high-level Warriors. By party-wide decision, when we quest we try to share the joy of smacking monsters around to everyone, so I habitually dump all the mana I get into strength boosts. I found it super annoying to manually click the Valorous Presence button all the time, so this script will convert all of your mana at any given point to whatever buff you ask it to. It is not required to run the syncer.
dates.py - this is totally a module I found somewhere--possibly on scriptabit?--to help me parse the different ways both programs handle UTC dates so that I can manipulate them with datetime.
hab_task.py - borrowed from Dee Dee's scriptabit version, but no longer actually identical; I have customized it quite a bit with an eye towards sending information useful to Todoist. What this does is create a class of objects for Habitica tasks and defines how to manipulate them. Most things are sliiiightly off from both Habitica's nomenclature (e.g. $HAB_TASK.name will return the name of the task although Habitica encodes the name as 'text' in its own dictionaries) or from the nomenclature used from the Todoist equivalent class (e.g. it's $HAB_TASK.completed but $TOD_TASK.complete).
init.py - this thing seriously just loads the rest of it.
main.py - This is another really important one--it's where most of the smaller routines live in the main code. This file contains routines for loading login information from the doc, adding tasks to habitica, removing tasks, etc. (Todoist requires fewer of these routines because I'm using todoist's native Python API, which can be found at www.developer.todoist.com.) Everything here is now using the most up-to-date Habitica API, which is I think something of an improvement on both previous versions of the program here and on todoist-habitrpg's form.
manaPull.py - This is really the equivalent of main for castSpells. It contains small routines that are important for castSpells to work but not really required for anything else.
oneWaySync.py - This is the main syncing program; in fact, when I go to sync my own Todoist and Habitica accounts, I usually do it by throwing "python oneWaySync.py" into the browser from the folder that contains all these scripts. It is big and kind of ugly and I should probably pull many of its smaller routines into main.py so they can be more effectively commented. As long as all its dependencies are met, it should be sufficient to sync everything. (It also isn't actually one-way any more! For an explanation of the name, see under basicSync.) Currently it is working suitably but has some trouble with repeating todoist tasks and/or dailies. I am trying to debug that now; will add that as an Issue in a moment. It has zero problems with non-repeating tasks and does... okay with repeating ones; its main problem is occasionally checking off todoist tasks when they really shouldn't be checked off.
task.py - I am pretty sure I just borrowed this from scriptabit. It's still being used SOMEWHERE in all this mess but I am not entirely sure exactly where. Ugh. It's another set of lists that are used to define task traits.
todo_task.py - This is the Todoist equivalent class defining file of hab_task.py.

Here's the scripts I have gone in and removed as, effectively, obsolete. They're now living in the OldCode folder:
basicSync - started as me going "okay I am doing way too much here, let's try rewriting the syncing script from scratch now that I've learned more because THIS IS NOT WORKING." oneWaySync also started the exact same way when I got frustrated with basicSync. They should both probably be renamed, especially as oneWaySync is no longer actually one-way!
basicSyncNoClass, mainNoClass - I wanted to see if I could make things shorter by just manipulating tasks directly as dictionaries instead of treating them as objects inside classes. This did not work and was way more irritating to me, so I scrapped the idea entirely.
habtod_matchdict.pkl - this is the old storage file that basicSync saves. As I'm not using basicSync, I figured that needed to be put away.
main_v1.py - original, more bloated version of main.py. No longer in use.

@eringiglio
Copy link
Owner

Er, @Zwirbel1 , @vj88 , I'm going to ping you in case this conversation is of interest to you guys as I work on the documentation. I'm going to also go ahead and put my lists of stuff that needs doing in as issues.

@Zwirbel1
Copy link

@eringiglio Perfect, thank you very much. I probably have time on the weekend to look into this again.

@rachteo
Copy link

rachteo commented Feb 16, 2018

When I tried running 'python oneWaySync.py' I got the following error:

ImportError: No module named requests

I got no clue about Python at all, what am I missing? I downloaded and unzipped the file normally, but can't seem to find the requests module...

@ksonney
Copy link
Contributor

ksonney commented Mar 5, 2018

@rachteo You need to install the requests python library, either with your package manager or with "pip install requests"

@Thalvarian
Copy link

Hiya, trying to get this to work. Tried running oneWaySync from powershell as well and also ran into an error in 'main.py' on line 100 (tod_login, tod_user = todoist.TodoistAPI(rv) ):

AttributeError: module 'todoist' has no attribute 'TodoistAPI'

I tried changing 'todoist' to 'pytodoist' but that would not help. Maybe the attribute is named differently these days? If so, what is it called?
Could very well be related to changes in the modules, but I figured I'd post here as well in case someone runs into the same problem (and knows how to fix it).

@jenmei
Copy link

jenmei commented Jun 24, 2019

@Thalvarian I had the same error. Seems like a problem with todoist-python under Python 2.7 (at least in my case). When I tried following the instructions on their README I got the same error as when running oneWaySync.py. I switched to Python 3, I get past the error. Then I get a KeyError on line todo_task.py line 47, which is:

        if self.__task_dict['date_string'] == None:

I changed this to

        if self.__task_dict.get('date_string', None) == None:

and syncing works. As far as I can tell, anyway; I didn't run a full sync because I have too many tasks in Todoist (enough that it would make Habitica really hard to navigate). Going to look into changing it to sync only today next.

@idmyn
Copy link

idmyn commented Sep 3, 2019

@jenmei Could you specify which specific Python version you're having success with? I've tried 2.7.0 and 2.7.16 and 3.7.3 with no luck. I'm stuck on the AttributeError: module 'todoist' has no attribute 'TodoistAPI'.

EDIT: I ran pip install todoist-python and then tried running oneWaySync.py again. I got to the KeyError mentioned by jenmei, which I was able to fix with the same edit that they made. I'm running Python 3.7.3, FWIW.

@kofm
Copy link

kofm commented Sep 30, 2019

@jenmei thanks for sharing, I was also able to fix with your edit.

I also wanted to sync only tasks due today, so I changed some lines in oneWaySync.py from:

tod_tasks = []
tod_items = tod_user.items
tod_tasklist = tod_items.all()
for i in range(0, len(tod_tasklist)):
    tod_tasks.append(TodTask(tod_tasklist[i].data))

to

tod_tasks = []
tod_items = tod_user.items
tod_tasklist = tod_items.all()
for i in range(0, len(tod_tasklist)):
    due = tod_tasklist[i]['due']
    if due:
            if due['date'] == datetime.utcnow().strftime("%Y-%m-%d"):
                tod_tasks.append(TodTask(tod_tasklist[i].data))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests