This commit is contained in:
Mathias Behrle committed 2011-06-14 13:02:19 +02:00
commit 4ef9bbb739
7 files changed
+82 -48

No files matched your search

+21 -16
View File
@@ -2,6 +2,7 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from __future__ import with_statement
from setuptools import setup, find_packages
import os
import glob
@@ -219,9 +220,12 @@ if os.name == 'nt':
query_loaders = Popen(os.path.join(gtk_dir,'bin','gdk-pixbuf-query-loaders'),
stdout=PIPE).stdout.read()
query_loaders = query_loaders.replace(gtk_dir.replace(os.sep, '/') + '/', '')
loaders = open(os.path.join(dist_dir, 'etc', 'gtk-2.0', 'gdk-pixbuf.loaders'), 'w')
loaders.writelines([line + "\n" for line in query_loaders.split(os.linesep)])
loaders.close()
loaders_path = os.path.join(dist_dir, 'etc', 'gtk-2.0',
'gdk-pixbuf.loaders')
with open(loaders_path, 'w') as loaders:
loaders.writelines([line + "\n" for line in
query_loaders.split(os.linesep)])
if os.path.isdir(os.path.join(dist_dir, 'lib')):
shutil.rmtree(os.path.join(dist_dir, 'lib'))
@@ -284,14 +288,13 @@ elif os.name == 'mac' \
query_pango = Popen(os.path.join(gtk_dir, 'bin', 'pango-querymodules'),
stdout=PIPE).stdout.read()
query_pango = query_pango.replace(gtk_dir, '@executable_path/../Resources')
pango_modules = open(os.path.join(resources_dir, 'pango.modules'), 'w')
pango_modules.write(query_pango)
pango_modules.close()
pango_modules_path = os.path.join(resources_dir, 'pango.modules')
with open(pango_modules_path, 'w') as pango_modules:
pango_modules.write(query_pango)
pangorc = open(os.path.join(resources_dir, 'pangorc'), 'w')
pangorc.write('[Pango]\n')
pangorc.write('ModuleFiles=./pango.modules\n')
pangorc.close()
with open(os.path.join(resources_dir, 'pangorc'), 'w') as pangorc:
pangorc.write('[Pango]\n')
pangorc.write('ModuleFiles=./pango.modules\n')
if os.path.isdir(os.path.join(gtk_2_dist_dir, gtk_binary_version, 'loaders')):
shutil.rmtree(os.path.join(gtk_2_dist_dir, gtk_binary_version, 'loaders'))
@@ -306,9 +309,10 @@ elif os.name == 'mac' \
query_loaders = Popen(os.path.join(gtk_dir,'bin','gdk-pixbuf-query-loaders'),
stdout=PIPE).stdout.read()
query_loaders = query_loaders.replace(gtk_dir, '@executable_path/../Resources')
loaders = open(os.path.join(resources_dir, 'gdk-pixbuf.loaders'), 'w')
loaders.write(query_loaders)
loaders.close()
loaders_path = os.path.join(resources_dir, 'gdk-pixbuf.loaders')
with open(loaders_path, 'w') as loaders:
loaders.write(query_loaders)
if os.path.isdir(os.path.join(gtk_2_dist_dir, gtk_binary_version, 'immodules')):
shutil.rmtree(os.path.join(gtk_2_dist_dir, gtk_binary_version, 'immodules'))
@@ -318,9 +322,10 @@ elif os.name == 'mac' \
query_immodules = Popen(os.path.join(gtk_dir, 'bin', 'gtk-query-immodules-2.0'),
stdout=PIPE).stdout.read()
query_immodules = query_immodules.replace(gtk_dir, '@executable_path/../Resources')
immodules = open(os.path.join(resources_dir, 'gtk.immodules'), 'w')
immodules.write(query_immodules)
immodules.close()
immodules_path = os.path.join(resources_dir, 'gtk.immodules')
with open(immodules_path, 'w') as immodules:
immodules.write(query_immodules)
shutil.copy(os.path.join(gtk_dir, 'share', 'themes', 'Clearlooks',
'gtk-2.0', 'gtkrc'), os.path.join(resources_dir, 'gtkrc'))
+3 -3
View File
@@ -1,5 +1,6 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from __future__ import with_statement
import time
import datetime
import tryton.rpc as rpc
@@ -58,9 +59,8 @@ class Action(object):
fp_name = os.path.join(dtemp,
name.replace(os.sep, '_').replace(os.altsep or os.sep, '_') \
+ os.extsep + type)
file_d = open(fp_name, 'wb')
file_d.write(base64.decodestring(data))
file_d.close()
with open(fp_name, 'wb') as file_d:
file_d.write(base64.decodestring(data))
if email_print:
mailto(to=email.get('to'), cc=email.get('cc'),
subject=email.get('subject'), body=email.get('body'),
+2
View File
@@ -130,6 +130,8 @@ def find_in_path(name):
def test_server_version(host, port):
version = rpc.server_version(host, port)
if not version:
return False
return version.split('.')[:2] == VERSION.split('.')[:2]
def refresh_dblist(host, port):
+13 -14
View File
@@ -1,5 +1,6 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from __future__ import with_statement
import os
from tryton.config import get_config_dir
@@ -15,23 +16,21 @@ class Fingerprints(dict):
def load(self):
if not os.path.isfile(KNOWN_HOSTS_PATH):
return
known_hosts = open(KNOWN_HOSTS_PATH)
for line in known_hosts.xreadlines():
line = line.strip()
try:
key, sha1 = line.split(' ')
host, port = key.rsplit(':', 1)
except ValueError:
continue
self[(host, port)] = sha1
known_hosts.close()
with open(KNOWN_HOSTS_PATH) as known_hosts:
for line in known_hosts.xreadlines():
line = line.strip()
try:
key, sha1 = line.split(' ')
host, port = key.rsplit(':', 1)
except ValueError:
continue
self[(host, port)] = sha1
def save(self):
lines = []
known_hosts = open(KNOWN_HOSTS_PATH, 'w')
known_hosts.writelines('%s:%s %s' % (host, port, sha1)
+ os.linesep for (host, port), sha1 in self.iteritems())
known_hosts.close()
with open(KNOWN_HOSTS_PATH, 'w') as known_hosts:
known_hosts.writelines('%s:%s %s' % (host, port, sha1)
+ os.linesep for (host, port), sha1 in self.iteritems())
def __setitem__(self, key, value):
assert isinstance(key, tuple)
+4 -6
View File
@@ -1634,9 +1634,8 @@ class Main(object):
dialog = DBRestore(self.window, filename=filename)
url, dbname, passwd, update = dialog.run(self.window)
if dbname:
file_p = open(filename, 'rb')
data_b64 = base64.encodestring(file_p.read())
file_p.close()
with open(filename, 'rb') as file_p:
data_b64 = base64.encodestring(file_p.read())
host, port = url.rsplit(':' , 1)
rpcprogress = common.RPCProgress('db_exec', (host, int(port),
'restore', dbname, passwd, data_b64, update), self.window)
@@ -1713,9 +1712,8 @@ class Main(object):
filename=dbname + '-' + time.strftime('%Y%m%d%H%M') + '.dump')
if filename:
file_ = open(filename, 'wb')
file_.write(dump)
file_.close()
with open(filename, 'wb') as file_:
file_.write(dump)
common.message(_("Database backuped successfully!"), \
parent=self.window)
else:
+36 -6
View File
@@ -505,6 +505,8 @@ class DBLogin(object):
except ConfigParser.NoOptionError:
username = ''
host = self.profiles.get(profile, 'host')
if ':' in host:
host = '[%s]' % host
port = self.profiles.get(profile, 'port')
self.entry_host.set_text('%s:%s' % (host, port))
self.entry_database.set_text(self.profiles.get(profile, 'database'))
@@ -522,8 +524,13 @@ class DBLogin(object):
self.move_active = True
def clear_profile_combo(self, entry, event):
host_entry = self.entry_host.get_text()
host, port = host_entry.split(':', 1) if ':' in host_entry else ('', '')
netloc = self.entry_host.get_text()
host = self.get_hostname(netloc)
try:
port = str(self.get_port(netloc))
except ValueError:
host = ''
port = ''
database = self.entry_database.get_text().strip()
for idx, profile_info in enumerate(self.profile_store):
if not profile_info[1]:
@@ -544,6 +551,21 @@ class DBLogin(object):
self.entry_database.props.visible = visibility
self.label_database.props.visible = visibility
def get_hostname(self, netloc):
if '[' in netloc and ']' in netloc:
return netloc.split(']')[0][1:]
elif ':' in netloc:
return netloc.split(':')[0]
else:
return netloc
def get_port(self, netloc):
netloc = netloc.split(']')[-1]
if ':' in netloc:
return int(netloc.split(':')[1])
else:
return 8070
def run(self, parent):
profile_name = CONFIG['login.profile']
can_use_profile = self.profiles.has_section(profile_name)
@@ -562,7 +584,11 @@ class DBLogin(object):
break
else:
self.combo_profile.set_active(-1)
self.entry_host.set_text('%s:%s' % (CONFIG['login.server'],
if ':' in CONFIG['login.server']:
host = '[%s]' % CONFIG['login.server']
else:
host = CONFIG['login.server']
self.entry_host.set_text('%s:%s' % (host,
CONFIG['login.port']))
db = CONFIG['login.db'] if CONFIG['login.db'] else ''
self.entry_database.set_text(db)
@@ -588,12 +614,16 @@ class DBLogin(object):
if active_profile != -1:
profile = self.profile_store[active_profile][0]
CONFIG['login.profile'] = profile
host, port = (self.entry_host.get_text().split(':', 1)
+ ['8070'])[:2]
netloc = self.entry_host.get_text()
host = self.get_hostname(netloc)
try:
port = int(port)
port = self.get_port(netloc)
except ValueError:
continue
if ':' in host:
hostname = '[%s]' % host
else:
hostname = host
if not common.test_server_version(host, port):
continue
database = self.entry_database.get_text()
+3 -3
View File
@@ -3,6 +3,7 @@
"""
Inter-Process Communication
"""
from __future__ import with_statement
import tempfile
import os
import threading
@@ -157,9 +158,8 @@ class FileClient(IPCClient):
return False
tmpdir = open(self.filename, 'r').readline().strip()
_, tmpfile = tempfile.mkstemp(dir=tmpdir, text=True)
tmpfile = open(tmpfile, 'w')
print >> tmpfile, message
tmpfile.close()
with open(tmpfile, 'w') as tmpfile:
print >> tmpfile, message
return True