Anyone know Python?

Chat about Linux in general

Anyone know Python?

Postby viking777 on Sun Sep 02, 2012 11:28 am

I must say I have really enjoyed installing manjaro linux recently, it has presented its challenges, but I have been able to cope with most of them except the one related here. The reason I can't deal with this is that it involves knowledge of Python code, and I just don't have any at all.

I installed the program 'clicompanion' without any errors, pacman says it is installed:

Code: Select all
pacman -Qs clicompanion
local/clicompanion-bzr 55-1
    A terminal that lets you store commands and create a command dictionary.


When I run it I get this:
Code: Select all
clicompanion
  File "/usr/bin/clicompanion", line 17
    print "Using locale in system"
                                 ^
SyntaxError: invalid syntax



Can anyone suggest what the syntax error might be? If I knew that I might be able to correct it. This is how it fits into the rest of the code:

Code: Select all
cat /usr/bin/clicompanion
#!/usr/bin/python

import locale
import gettext
import os
import sys
from optparse import OptionParser


share_dirs = os.environ.get('XDG_BASE_PDATA',
                            '/usr/local/share:/usr/share').split(os.pathsep)

BASEDIR = ''
for path in share_dirs:
    if (os.path.exists('%s/clicompanion/'%path)):
        BASEDIR = '%s/clicompanion/'%path
        print "Using locale in system"
        break
if not BASEDIR:
    BASEDIR = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
    if (os.path.exists(BASEDIR)):
        print "ERROR: locales dir not found."
        sys.exit(1)
    print "Using locale in source code folder"


parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.1")
parser.add_option("-f", "--file", dest="conffile",
                  help="Configuration file to use.", metavar="FILE")
parser.add_option("-c", "--cheatsheet", dest="cheatsheet",
                  help="Read cheatsheet from FILE", metavar="FILE")
parser.add_option("-d", "--debug", dest="debug", action='store_true',
                  default=False, help="Print debug messages",)

(options, args) = parser.parse_args()


def get_language():
    """Return the language to be used by the system.

    If it finds the system language in the translated files, it
    returns it, otherwise it just returns None.
    """
    loc = locale.setlocale(locale.LC_ALL, "")
    loc = loc[:2]
    traducidos = os.listdir(locale_dir)
    if loc in traducidos:
        return loc
    return
   

locale_dir = os.path.join(BASEDIR, "locale")
gettext.install('clicompanion', locale_dir, unicode=True)
idioma = get_language()
if idioma is not None:
    mo = os.path.join(locale_dir, '%s/LC_MESSAGES/clicompanion.mo' % idioma)
    if not os.access(mo, os.F_OK):
        raise IOError("The l10n directory (for language %r) exists but "
                      "not the clicompanion.mo file" % idioma)
    trans = gettext.translation('clicompanion', locale_dir, languages=[idioma])
    trans.install(unicode=True)


if __name__ == "__main__":
    from clicompanionlib.view import run
    run( options )


I wouldn't lose any sleep over it btw, I won't be, it is only a minor niggle :)
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am

Linux Mint is funded by ads and donations.
 

Re: Anyone know Python?

Postby grizzler on Sun Sep 02, 2012 1:59 pm

Which version of python is installed on that system? I would expect a recent one in the 2 branch (2.6, 2.7), but the error suggests the print command without parentheses isn't accepted, so it might be 3. Try python --version to check the version number.

http://docs.pythonsprints.com/python3_p ... rting.html

I'm by no means a python expert by the way. Just ran into this problem myself when I played with python a bit.
grizzler
Level 4
Level 4
 
Posts: 422
Joined: Wed Jun 15, 2011 5:19 pm
Location: The Hague, NL

Re: Anyone know Python?

Postby viking777 on Mon Sep 03, 2012 5:54 am

Thanks very much for that reply grizzler, it gave me a lot to think about. It turns out I have both version 2.7 and 3.2 installed, so in order to overcome the sytax error all I had to do was to change the opening line of the clicompanion executable to:

Code: Select all
#!/usr/bin/python2.7


Sadly that doesn't get me very far because it just moves on to the next error message in the code:

Code: Select all
ERROR: locales dir not found.


I could probably play this game for ever, the simple answer is that the program isn't compatible with this distro, no idea why though, every other program I installed knows what locale I am using.

Thanks again for you help though, much appreciated.
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am

Re: Anyone know Python?

Postby duanedesign on Tue Jan 01, 2013 2:03 pm

Glad to hear you have tried CLI Companion. We have added a lot of new features and bug fixes. Integration with comandlinefu.com is a cool feature. We also made it easier to hide the 'command dictionary'. It is easy to hide all the 'extras' and CLI Companion looks and acts more like gnome-terminal (for example).
I would love to look into your bug and see what night be causing this. I have a feeling we fixed this not to long ago. I will be more then happy to look into it for you.

Any input is greatly appreciated.
duanedesign
Level 1
Level 1
 
Posts: 1
Joined: Tue Jan 01, 2013 1:51 pm

Re: Anyone know Python?

Postby viking777 on Tue Jan 01, 2013 2:49 pm

duanedesign wrote:Glad to hear you have tried CLI Companion. We have added a lot of new features and bug fixes. Integration with comandlinefu.com is a cool feature. We also made it easier to hide the 'command dictionary'. It is easy to hide all the 'extras' and CLI Companion looks and acts more like gnome-terminal (for example).
I would love to look into your bug and see what night be causing this. I have a feeling we fixed this not to long ago. I will be more then happy to look into it for you.

Any input is greatly appreciated.


Very kind of you to offer, but I managed to get it going eventually without you. To see how you should read this thread here:

http://forum.manjaro.org/index.php?topi ... 96#msg8196
Fujitsu Lifebook AH532. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Lubuntu 13.10,Ubuntu12.10 (Unity), Mint16 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 14
Level 14
 
Posts: 5153
Joined: Mon Dec 01, 2008 11:21 am


Return to Chat about Linux

Who is online

Users browsing this forum: No registered users and 5 guests