Anyone know Python?

Chat about Linux in general
Forum rules
Do not post support questions here. Before you post read the forum rules. Topics in this forum are automatically closed 6 months after creation.
Locked
viking777

Anyone know Python?

Post by viking777 »

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 :)
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
grizzler

Re: Anyone know Python?

Post by grizzler »

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.
viking777

Re: Anyone know Python?

Post by viking777 »

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.
duanedesign

Re: Anyone know Python?

Post by duanedesign »

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.
viking777

Re: Anyone know Python?

Post by viking777 »

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
Locked

Return to “Chat about Linux”