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

Debian LMDE + Conky + gcalcli = issue #16

Closed
ghost opened this issue May 21, 2012 · 11 comments
Closed

Debian LMDE + Conky + gcalcli = issue #16

ghost opened this issue May 21, 2012 · 11 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented May 21, 2012

Hello

After switching from LinuxMint to LinuxMint Debian Edition I've got a problem with gcalcli.
After little investigation I've founded cause (copied below).

I'll be much appreciated for any help
Best regards to all.

My error:
Conky: desktop window (10000a5) is subwindow of root window (be)
Conky: window type - override
Conky: drawing to created window (0x2400001)
Conky: drawing to double buffer
Traceback (most recent call last):
File "/usr/bin/gcalcli", line 1529, in
BowChickaWowWow()
File "/usr/bin/gcalcli", line 1474, in BowChickaWowWow
gcal.CalQuery(args[0], count=int(args[1]))
File "/usr/bin/gcalcli", line 1007, in CalQuery
self._GraphEvents(cmd, start, count, eventList)
File "/usr/bin/gcalcli", line 692, in _GraphEvents
PrintMsg(CLR_NRM(), line + "\n")
File "/usr/bin/gcalcli", line 232, in PrintMsg
sys.stdout.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0144' in position 95: ordinal not in range(128)

@insanum
Copy link
Owner

insanum commented May 21, 2012

Did you try the latest code in the git master branch?

@ghost
Copy link
Author

ghost commented May 22, 2012

Yes.
I've copied content of https://raw.github.com/insanum/gcalcli/master/gcalcli, but still have the same error.

Oh, just checked right now and from command line i've good response (good calendar) - only when i run gcalcli from conky script i have that issue.

@ghost
Copy link
Author

ghost commented Jun 5, 2012

OK, so developer wasn't very helpful and I had to find workaround:

  1. git clone http://www.tablix.org/~avian/git/unidecode.git
  2. cd unidecode
  3. sudo python setup.py install
  4. sudo vi /usr/bin/gcalcli
  5. above “from Queue import Queue” add “from unidecode import unidecode”
  6. find “def PrintMsg(color, msg)”, and else statement should look like this "sys.stdout.write(unidecode(msg))"

All thanks goes to "Gilles Lenfant" (http://www.peterbe.com/plog/unicode-to-ascii#c358f0d)

@BeniaminK
Copy link

Or in PrintMsg function, after every msg one should encode to utf-8, so msg.encode("utf-8") should work properly.

@Unkuiri
Copy link

Unkuiri commented Sep 30, 2012

Following what is said here: http://stackoverflow.com/questions/8016236/python-unicode-handling-differences-between-print-and-sys-stdout-write
"A better solution might be to replace sys.stdout with a wrapper". This is accomplished by adding this:

class StdOut(object):
    def write(self, string):
        if isinstance(string, unicode):
            string = string.encode(sys.__stdout__.encoding)
        sys.__stdout__.write(string)

sys.stdout = StdOut()

to the part just next to the import part, for example on line 62 or 63 and on the def PrintMsg(color, msg) part the else statement should look like sys.stdout.write(msg)

Hope this helps

@insanum
Copy link
Owner

insanum commented Jan 13, 2013

@ihatelogin don't you just hate it when the developer isn't helpful? Sucks I know, but sometimes those developers are just way to busy and simple python scripts are never a priority.

There was a new "--locale" option added to gcalcli. That might help address this issue. If not it is encouraged you take some time to create a github pull request that contains a proper fix.

@tresni
Copy link
Collaborator

tresni commented Jan 30, 2013

This is probably the same issue I talked about over here in #8 and is likely fixed with b713a8c . Right now I've tagged that as 2.5 milestone as I really need more people then just me to test it. I'm actually inclined to mark this as a duplicate.

@ghost ghost assigned tresni Jan 30, 2013
@insanum
Copy link
Owner

insanum commented Feb 1, 2013

Got an email that unicode in the month names break the calw and calm output. Don't know if @tresni fix fixes this problem.
screenshot

@tresni
Copy link
Collaborator

tresni commented Feb 5, 2013

Probably not, though I think I know where the issue is. I believe the east_asian_width calls only apply to descriptions, not month/day names so that could definitely be an issue.

@insanum
Copy link
Owner

insanum commented Feb 5, 2013

We should probably filter all terminal output through a single function that does the proper conversions. This unicode stuff has plagued gcalcli for quite some time now. Maybe unifying the output path will help. Thoughts?

@tresni
Copy link
Collaborator

tresni commented Feb 5, 2013

Agree. I've found a couple other odd output errors. If I set my output width too big (variable depending on terminal window size) and have more one meeting in the day, I get newlines in the output where it shouldn't be...

2 bhartvigsen_baldeagle_ _ zsh

@tresni tresni closed this as completed in 88dcdff Mar 16, 2013
tresni added a commit that referenced this issue Mar 16, 2013
Thanks to KaiQ, DerKleineLeif, msoida, Unkuiri and everyone else who supplied
information on the issues and potential solutions.
Fixes #8. Fixes #16. Fixes #62.
yarikoptic added a commit to yarikoptic/gcalcli that referenced this issue Nov 19, 2014
* tag 'v2.4.2': (70 commits)
  Update ChangeLog for a 2.4.2 release
  Fix a bug where multiple events would try to print on a single line in calw & calm
  Make sure we are playing with unicode in all the right places
  Finally fix issues with unicode vs ascii. Thanks to KaiQ, DerKleineLeif, msoida, Unkuiri and everyone else who supplied information on the issues and potential solutions. Fixes insanum#8. Fixes insanum#16. Fixes insanum#62.
  Fix tsv output
  Update everything to show 2.4 release
  simplejson is the base for json, use stdlib if simplejson isn't there
  print event date as YYYY-MM-DD for the search command
  added link info to tsv agenda output (--detail-url=short works for tsv as well)
  added ability to print links for events and shorten them via goo.gl
  added ascii text box around description in agenda output
  added some flair, and NO I don't need 37 pieces of flair to express myself o.O
  fixed listing of location and reminder information in the agenda
  Whoops, should really import the real library
  That space was bugging me
  Support fuzzy dates.  Fixes insanum#11.
  only allow reminders to be added to ics events that don't have a recurrence
  don't show description containing only whitespace chars
  added date samples in dd/mm/yyyy format
  updated docs on how to use the 'remind' command for event notifications
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants