do not require argparse anymore, chmod in the directory in the python process directly, fix a little bit the Mafile

This commit is contained in:
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 2010-09-07 23:36:57 +00:00
parent 7d7f585ed6
commit f8ab739a36
4 changed files with 24 additions and 23 deletions

View file

@ -19,7 +19,7 @@ install:
mkdir -p $(DESTDIR)
$(INSTALL) -d $(DESTDIR)$(LOCALEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(DATADIR)/poezio $(DESTDIR)$(DATADIR)/poezio/data $(DESTDIR)$(DATADIR)/poezio/src/ $(DESTDIR)$(DATADIR)/poezio/src/xmpp $(DESTDIR)$(DATADIR)/poezio/data/themes $(DESTDIR)$(MANDIR)/man1
$(CP) data/* $(DESTDIR)$(DATADIR)/poezio/data/ -R
$(CP) -R data/* $(DESTDIR)$(DATADIR)/poezio/data/
$(CHMOD) 644 -R $(DESTDIR)$(DATADIR)/poezio/data/
$(INSTALL) -m644 data/poezio.1 $(DESTDIR)$(MANDIR)/man1/
@ -28,12 +28,13 @@ install:
done
echo "#!/usr/bin/env sh" > $(DESTDIR)$(BINDIR)/poezio
echo "cd $(DATADIR)/poezio/src/ && python3 poezio.py" >> $(DESTDIR)$(BINDIR)/poezio
echo "python3 $(DATADIR)/poezio/src/poezio.py" >> $(DESTDIR)$(BINDIR)/poezio
chmod 755 $(DESTDIR)$(BINDIR)/poezio
uninstall:
rm -f $(DESTDIR)$(BINDIR)/poezio
rm -rf $(DESTDIR)$(DATADIR)/poezio
rm -rf $(DESTDIR)$(MANDIR)/man1/poezio.1
pot:
xgettext src/*.py --from-code=utf-8 --keyword=_ -o locale/poezio.pot

View file

@ -23,11 +23,7 @@ from/to the config file
from configparser import RawConfigParser, NoOptionError
from os import environ, makedirs, path
from shutil import copy2
try:
import argparse
HAVE_ARGPARSE = True
except ImportError:
HAVE_ARGPARSE = False
from optparse import OptionParser
class Config(RawConfigParser):
"""
@ -139,15 +135,11 @@ except OSError:
if not path.isfile(CONFIG_PATH+'poezio.cfg'):
copy2('../data/default_config.cfg', CONFIG_PATH+'poezio.cfg')
if HAVE_ARGPARSE:
parser = argparse.ArgumentParser(prog="poezio", description='An XMPP ncurses client.')
parser.add_argument('-f', '--file', default=CONFIG_PATH+'poezio.cfg', help='the config file you want to use', metavar="FILE")
args = parser.parse_args()
filename = args.file
else:
filename = CONFIG_PATH+'poezio.cfg'
config = Config(filename)
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename", default=CONFIG_PATH+'poezio.cfg',
help="the config file you want to use", metavar="CONFIG_FILE")
(options, args) = parser.parse_args()
config = Config(options.filename)
if __name__ == '__main__':
# tests

View file

@ -20,6 +20,12 @@
Starting point of poezio. Launches both the Connection and Gui
"""
import os
# chdir in the source directory, so that import are never failed
# also, no need to use a sh script to "cd" in this directoy
# before launching poezio.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
import curses
import sys
import traceback
@ -49,16 +55,18 @@ def exception_handler(type_, value, trace):
then exit the program
"""
my_stderr.restaure()
curses.endwin()
curses.echo()
try:
curses.endwin()
curses.echo()
except: # if an exception is raised but initscr has never been called yet
pass
traceback.print_exception(type_, value, trace, None, sys.stderr)
import os # used to quit the program even from a thread
os.abort()
# import os # used to quit the program even from a thread
# os.abort()
sys.excepthook = exception_handler
import signal
import os
from connection import Connection
from config import config

View file

@ -113,7 +113,7 @@ class Topic(Win):
g_lock.acquire()
self.win.erase()
if not jid:
self.win.addnstr(0, 0, topic[:self.width], curses.color_pair(theme.COLOR_TOPIC_BAR))
self.win.addnstr(0, 0, topic[:self.width-1], curses.color_pair(theme.COLOR_TOPIC_BAR))
while True:
try:
self.win.addch(' ', curses.color_pair(theme.COLOR_TOPIC_BAR))
@ -167,7 +167,7 @@ class RoomInfo(Win):
break
(y, x) = self.win.getyx()
self.win.addstr(y, x-1, '] '+ current.name, curses.color_pair(theme.COLOR_INFORMATION_BAR))
self.print_scroll_position(current)
# self.print_scroll_position(current)
while True:
try:
self.win.addstr(' ', curses.color_pair(theme.COLOR_INFORMATION_BAR))