openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #25628
[Merge] lp:~alisonken1/openlp/projector_text_fixes into lp:openlp
Ken Roberts has proposed merging lp:~alisonken1/openlp/projector_text_fixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~alisonken1/openlp/projector_text_fixes/+merge/246643
Fix text for translators.
Made all text format strings for projector files consistent.
lp:~alisonken1/openlp/projector_text_fixes (revision 2476)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/867/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/799/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/745/
[FAILURE] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/651/
Passes local pep8
--
Your team OpenLP Core is requested to review the proposed merge of lp:~alisonken1/openlp/projector_text_fixes into lp:openlp.
=== modified file 'openlp/core/lib/projector/db.py'
--- openlp/core/lib/projector/db.py 2014-12-31 10:58:13 +0000
+++ openlp/core/lib/projector/db.py 2015-01-15 20:46:09 +0000
@@ -81,7 +81,7 @@
"""
Returns a basic representation of a Manufacturer table entry.
"""
- return '<Manufacturer(name="%s")>' % self.name
+ return '<Manufacturer(name="{}")>'.format(self.name)
name = Column(String(30))
models = relationship('Model',
@@ -108,7 +108,7 @@
"""
Returns a basic representation of a Model table entry.
"""
- return '<Model(name=%s)>' % self.name
+ return '<Model(name{})>'.format(self.name)
manufacturer_id = Column(Integer, ForeignKey('manufacturer.id'))
name = Column(String(20))
@@ -138,8 +138,9 @@
"""
Return basic representation of Source table entry.
"""
- return '<Source(pjlink_name="%s", pjlink_code="%s", text="%s")>' % \
- (self.pjlink_name, self.pjlink_code, self.text)
+ return '<Source(pjlink_name="{}", pjlink_code="%{}", text="{}")>'.format(self.pjlink_name,
+ self.pjlink_code,
+ self.text)
model_id = Column(Integer, ForeignKey('model.id'))
pjlink_name = Column(String(15))
pjlink_code = Column(String(2))
@@ -169,11 +170,11 @@
"""
Return basic representation of Source table entry.
"""
- return '< Projector(id="%s", ip="%s", port="%s", pin="%s", name="%s", location="%s",' \
- 'notes="%s", pjlink_name="%s", manufacturer="%s", model="%s", other="%s",' \
- 'sources="%s", source_list="%s") >' % (self.id, self.ip, self.port, self.pin, self.name, self.location,
- self.notes, self.pjlink_name, self.manufacturer, self.model,
- self.other, self.sources, self.source_list)
+ return '< Projector(id="{}", ip="{}", port="{}", pin="{}", name="{}", location="{}",' \
+ 'notes="{}", pjlink_name="{}", manufacturer="{}", model="{}", other="{}",' \
+ 'sources="{}", source_list="{}") >'.format(self.id, self.ip, self.port, self.pin, self.name, self.location,
+ self.notes, self.pjlink_name, self.manufacturer, self.model,
+ self.other, self.sources, self.source_list)
ip = Column(String(100))
port = Column(String(8))
pin = Column(String(20))
@@ -210,10 +211,10 @@
"""
Return basic representation of Source table entry.
"""
- return '<ProjectorSource(id="%s", code="%s", text="%s", projector_id="%s")>' % (self.id,
- self.code,
- self.text,
- self.projector_id)
+ return '<ProjectorSource(id="{}", code="{}", text="{}", projector_id="{}")>'.format(self.id,
+ self.code,
+ self.text,
+ self.projector_id)
code = Column(String(3))
text = Column(String(20))
projector_id = Column(Integer, ForeignKey('projector.id'))
@@ -224,10 +225,10 @@
Class to access the projector database.
"""
def __init__(self, *args, **kwargs):
- log.debug('ProjectorDB().__init__(args="%s", kwargs="%s")' % (args, kwargs))
+ log.debug('ProjectorDB().__init__(args="{}", kwargs="{}")'.format(args, kwargs))
super().__init__(plugin_name='projector',
init_schema=self.init_schema)
- log.debug('ProjectorDB() Initialized using db url %s' % self.db_url)
+ log.debug('ProjectorDB() Initialized using db url {}'.format(self.db_url))
def init_schema(*args, **kwargs):
"""
@@ -247,13 +248,13 @@
:param dbid: DB record id
:returns: Projector() instance
"""
- log.debug('get_projector_by_id(id="%s")' % dbid)
+ log.debug('get_projector_by_id(id="{}")'.format(dbid))
projector = self.get_object_filtered(Projector, Projector.id == dbid)
if projector is None:
# Not found
- log.warn('get_projector_by_id() did not find %s' % id)
+ log.warn('get_projector_by_id() did not find {}'.format(id))
return None
- log.debug('get_projectorby_id() returning 1 entry for "%s" id="%s"' % (dbid, projector.id))
+ log.debug('get_projectorby_id() returning 1 entry for "{}" id="{}"'.format(dbid, projector.id))
return projector
def get_projector_all(self):
@@ -269,7 +270,7 @@
return return_list
for new_projector in new_list:
return_list.append(new_projector)
- log.debug('get_all() returning %s item(s)' % len(return_list))
+ log.debug('get_all() returning {} item(s)'.format(len(return_list)))
return return_list
def get_projector_by_ip(self, ip):
@@ -279,13 +280,13 @@
:param ip: Host IP/Name
:returns: Projector() instance
"""
- log.debug('get_projector_by_ip(ip="%s")' % ip)
+ log.debug('get_projector_by_ip(ip="{}")'.format(ip))
projector = self.get_object_filtered(Projector, Projector.ip == ip)
if projector is None:
# Not found
- log.warn('get_projector_by_ip() did not find %s' % ip)
+ log.warn('get_projector_by_ip() did not find {}'.format(ip))
return None
- log.debug('get_projectorby_ip() returning 1 entry for "%s" id="%s"' % (ip, projector.id))
+ log.debug('get_projectorby_ip() returning 1 entry for "{}" id="{}"'.format(ip, projector.id))
return projector
def get_projector_by_name(self, name):
@@ -295,13 +296,13 @@
:param name: Name of projector
:returns: Projector() instance
"""
- log.debug('get_projector_by_name(name="%s")' % name)
+ log.debug('get_projector_by_name(name="{}")'.format(name))
projector = self.get_object_filtered(Projector, Projector.name == name)
if projector is None:
# Not found
- log.warn('get_projector_by_name() did not find "%s"' % name)
+ log.warn('get_projector_by_name() did not find "{}"'.format(name))
return None
- log.debug('get_projector_by_name() returning one entry for "%s" id="%s"' % (name, projector.id))
+ log.debug('get_projector_by_name() returning one entry for "{}" id="{}"'.format(name, projector.id))
return projector
def add_projector(self, projector):
@@ -315,13 +316,13 @@
"""
old_projector = self.get_object_filtered(Projector, Projector.ip == projector.ip)
if old_projector is not None:
- log.warn('add_new() skipping entry ip="%s" (Already saved)' % old_projector.ip)
+ log.warn('add_new() skipping entry ip="{}" (Already saved)'.format(old_projector.ip))
return False
log.debug('add_new() saving new entry')
- log.debug('ip="%s", name="%s", location="%s"' % (projector.ip,
- projector.name,
- projector.location))
- log.debug('notes="%s"' % projector.notes)
+ log.debug('ip="{}", name="{}", location="{}"'.format(projector.ip,
+ projector.name,
+ projector.location))
+ log.debug('notes="{}"'.format(projector.notes))
return self.save_object(projector)
def update_projector(self, projector=None):
@@ -340,7 +341,7 @@
if old_projector is None:
log.error('Edit called on projector instance not in database - cancelled')
return False
- log.debug('(%s) Updating projector with dbid=%s' % (projector.ip, projector.id))
+ log.debug('({}) Updating projector with dbid={}'.format(projector.ip, projector.id))
old_projector.ip = projector.ip
old_projector.name = projector.name
old_projector.location = projector.location
@@ -364,9 +365,9 @@
"""
deleted = self.delete_object(Projector, projector.id)
if deleted:
- log.debug('delete_by_id() Removed entry id="%s"' % projector.id)
+ log.debug('delete_by_id() Removed entry id="{}"'.format(projector.id))
else:
- log.error('delete_by_id() Entry id="%s" not deleted for some reason' % projector.id)
+ log.error('delete_by_id() Entry id="{}" not deleted for some reason'.format(projector.id))
return deleted
def get_source_list(self, projector):
@@ -402,9 +403,9 @@
source_entry = self.get_object_filtered(ProjetorSource, ProjectorSource.id == source)
if source_entry is None:
# Not found
- log.warn('get_source_by_id() did not find "%s"' % source)
+ log.warn('get_source_by_id() did not find "{}"'.format(source))
return None
- log.debug('get_source_by_id() returning one entry for "%s""' % (source))
+ log.debug('get_source_by_id() returning one entry for "{}""'.format(source))
return source_entry
def get_source_by_code(self, code, projector_id):
@@ -420,9 +421,9 @@
ProjectorSource.projector_id == projector_id))
if source_entry is None:
# Not found
- log.warn('get_source_by_id() did not find code="%s" projector_id="%s"' % (code, projector_id))
+ log.warn('get_source_by_id() did not find code="{}" projector_id="{}"'.format(code, projector_id))
return None
- log.debug('get_source_by_id() returning one entry for code="%s" projector_id="%s"' % (code, projector_id))
+ log.debug('get_source_by_id() returning one entry for code="{}" projector_id="{}"'.format(code, projector_id))
return source_entry
def add_source(self, source):
@@ -431,6 +432,6 @@
:param source: ProjectorSource() instance to add
"""
- log.debug('Saving ProjectorSource(projector_id="%s" code="%s" text="%s")' % (source.projector_id,
- source.code, source.text))
+ log.debug('Saving ProjectorSource(projector_id="{}" code="{}" text="{}")'.format(source.projector_id,
+ source.code, source.text))
return self.save_object(source)
=== modified file 'openlp/core/lib/projector/pjlink1.py'
--- openlp/core/lib/projector/pjlink1.py 2014-12-31 10:58:13 +0000
+++ openlp/core/lib/projector/pjlink1.py 2015-01-15 20:46:09 +0000
@@ -63,7 +63,7 @@
PJLINK_PREFIX = '%'
PJLINK_CLASS = '1'
-PJLINK_HEADER = '%s%s' % (PJLINK_PREFIX, PJLINK_CLASS)
+PJLINK_HEADER = '{}{}'.format(PJLINK_PREFIX, PJLINK_CLASS)
PJLINK_SUFFIX = CR
@@ -96,7 +96,7 @@
:param poll_time: Time (in seconds) to poll connected projector
:param socket_timeout: Time (in seconds) to abort the connection if no response
"""
- log.debug('PJlink(args="%s" kwargs="%s")' % (args, kwargs))
+ log.debug('PJlink(args="{}" kwargs="{}")'.format(args, kwargs))
self.name = name
self.ip = ip
self.port = port
@@ -152,7 +152,7 @@
"""
Reset projector-specific information to default
"""
- log.debug('(%s) reset_information() connect status is %s' % (self.ip, self.state()))
+ log.debug('({}) reset_information() connect status is {}'.format(self.ip, self.state()))
self.power = S_OFF
self.pjlink_name = None
self.manufacturer = None
@@ -175,7 +175,7 @@
"""
Connects signals to methods when thread is started.
"""
- log.debug('(%s) Thread starting' % self.ip)
+ log.debug('({}) Thread starting'.format(self.ip))
self.i_am_running = True
self.connected.connect(self.check_login)
self.disconnected.connect(self.disconnect_from_host)
@@ -185,7 +185,7 @@
"""
Cleanups when thread is stopped.
"""
- log.debug('(%s) Thread stopped' % self.ip)
+ log.debug('({}) Thread stopped'.format(self.ip))
try:
self.connected.disconnect(self.check_login)
except TypeError:
@@ -211,7 +211,7 @@
Aborts connection and closes socket in case of brain-dead projectors.
Should normally be called by socket_timer().
"""
- log.debug('(%s) socket_abort() - Killing connection' % self.ip)
+ log.debug('({}) socket_abort() - Killing connection'.format(self.ip))
self.disconnect_from_host(abort=True)
def poll_loop(self):
@@ -221,7 +221,7 @@
"""
if self.state() != self.ConnectedState:
return
- log.debug('(%s) Updating projector status' % self.ip)
+ log.debug('({}) Updating projector status'.format(self.ip))
# Reset timer in case we were called from a set command
if self.timer.interval() < self.poll_time:
# Reset timer to 5 seconds
@@ -281,11 +281,11 @@
self.status_connect = S_CONNECTED
self.projector_status = status
(status_code, status_message) = self._get_status(self.status_connect)
- log.debug('(%s) status_connect: %s: %s' % (self.ip, status_code, status_message if msg is None else msg))
+ log.debug('({}) status_connect: {}: {}'.format(self.ip, status_code, status_message if msg is None else msg))
(status_code, status_message) = self._get_status(self.projector_status)
- log.debug('(%s) projector_status: %s: %s' % (self.ip, status_code, status_message if msg is None else msg))
+ log.debug('({}) projector_status: {}: {}'.format(self.ip, status_code, status_message if msg is None else msg))
(status_code, status_message) = self._get_status(self.error_status)
- log.debug('(%s) error_status: %s: %s' % (self.ip, status_code, status_message if msg is None else msg))
+ log.debug('({}) error_status: {}: {}'.format(self.ip, status_code, status_message if msg is None else msg))
self.changeStatus.emit(self.ip, status, message)
@pyqtSlot()
@@ -296,27 +296,27 @@
:param data: Optional data if called from another routine
"""
- log.debug('(%s) check_login(data="%s")' % (self.ip, data))
+ log.debug('({}) check_login(data="{}")'.format(self.ip, data))
if data is None:
# Reconnected setup?
if not self.waitForReadyRead(2000):
# Possible timeout issue
- log.error('(%s) Socket timeout waiting for login' % self.ip)
+ log.error('({}) Socket timeout waiting for login'.format(self.ip))
self.change_status(E_SOCKET_TIMEOUT)
return
read = self.readLine(self.maxSize)
dontcare = self.readLine(self.maxSize) # Clean out the trailing \r\n
if read is None:
- log.warn('(%s) read is None - socket error?' % self.ip)
+ log.warn('({}) read is None - socket error?'.format(self.ip))
return
elif len(read) < 8:
- log.warn('(%s) Not enough data read)' % self.ip)
+ log.warn('({}) Not enough data read)'.format(self.ip))
return
data = decode(read, 'ascii')
# Possibility of extraneous data on input when reading.
# Clean out extraneous characters in buffer.
dontcare = self.readLine(self.maxSize)
- log.debug('(%s) check_login() read "%s"' % (self.ip, data.strip()))
+ log.debug('({}) check_login() read "{}"'.format(self.ip, data.strip()))
# At this point, we should only have the initial login prompt with
# possible authentication
# PJLink initial login will be:
@@ -331,25 +331,25 @@
else:
# Process initial connection
data_check = data.strip().split(' ')
- log.debug('(%s) data_check="%s"' % (self.ip, data_check))
+ log.debug('({}) data_check="{}"'.format(self.ip, data_check))
# Check for projector reporting an error
if data_check[1].upper() == 'ERRA':
# Authentication error
self.disconnect_from_host()
self.change_status(E_AUTHENTICATION)
- log.debug('(%s) emitting projectorAuthentication() signal' % self.name)
+ log.debug('({}) emitting projectorAuthentication() signal'.format(self.name))
return
elif data_check[1] == '0' and self.pin is not None:
# Pin set and no authentication needed
self.disconnect_from_host()
self.change_status(E_AUTHENTICATION)
- log.debug('(%s) emitting projectorNoAuthentication() signal' % self.name)
+ log.debug('({}) emitting projectorNoAuthentication() signal'.format(self.name))
self.projectorNoAuthentication.emit(self.name)
return
elif data_check[1] == '1':
# Authenticated login with salt
- log.debug('(%s) Setting hash with salt="%s"' % (self.ip, data_check[2]))
- log.debug('(%s) pin="%s"' % (self.ip, self.pin))
+ log.debug('({}) Setting hash with salt="{}"'.format(self.ip, data_check[2]))
+ log.debug('({}) pin="{}"'.format(self.ip, self.pin))
salt = qmd5_hash(salt=data_check[2], data=self.pin)
else:
salt = None
@@ -360,7 +360,7 @@
self.send_command(cmd='CLSS', salt=salt)
self.waitForReadyRead()
if (not self.no_poll) and (self.state() == self.ConnectedState):
- log.debug('(%s) Starting timer' % self.ip)
+ log.debug('({}) Starting timer'.format(self.ip))
self.timer.setInterval(2000) # Set 2 seconds for initial information
self.timer.start()
@@ -369,15 +369,15 @@
"""
Socket interface to retrieve data.
"""
- log.debug('(%s) get_data(): Reading data' % self.ip)
+ log.debug('({}) get_data(): Reading data'.format(self.ip))
if self.state() != self.ConnectedState:
- log.debug('(%s) get_data(): Not connected - returning' % self.ip)
+ log.debug('({}) get_data(): Not connected - returning'.format(self.ip))
self.send_busy = False
return
read = self.readLine(self.maxSize)
if read == -1:
# No data available
- log.debug('(%s) get_data(): No data available (-1)' % self.ip)
+ log.debug('({}) get_data(): No data available (-1)'.format(self.ip))
self.send_busy = False
self.projectorReceivedData.emit()
return
@@ -387,11 +387,11 @@
data = data_in.strip()
if len(data) < 7:
# Not enough data for a packet
- log.debug('(%s) get_data(): Packet length < 7: "%s"' % (self.ip, data))
+ log.debug('({}) get_data(): Packet length < 7: "{}"'.format(self.ip, data))
self.send_busy = False
self.projectorReceivedData.emit()
return
- log.debug('(%s) get_data(): Checking new data "%s"' % (self.ip, data))
+ log.debug('({}) get_data(): Checking new data "{}"'.format(self.ip, data))
if data.upper().startswith('PJLINK'):
# Reconnected from remote host disconnect ?
self.check_login(data)
@@ -399,7 +399,7 @@
self.projectorReceivedData.emit()
return
elif '=' not in data:
- log.warn('(%s) get_data(): Invalid packet received' % self.ip)
+ log.warn('({}) get_data(): Invalid packet received'.format(self.ip))
self.send_busy = False
self.projectorReceivedData.emit()
return
@@ -407,15 +407,15 @@
try:
(prefix, class_, cmd, data) = (data_split[0][0], data_split[0][1], data_split[0][2:], data_split[1])
except ValueError as e:
- log.warn('(%s) get_data(): Invalid packet - expected header + command + data' % self.ip)
- log.warn('(%s) get_data(): Received data: "%s"' % (self.ip, read))
+ log.warn('({}) get_data(): Invalid packet - expected header + command + data'.format(self.ip))
+ log.warn('({}) get_data(): Received data: "{}"'.format(self.ip, read))
self.change_status(E_INVALID_DATA)
self.send_busy = False
self.projectorReceivedData.emit()
return
if not (self.pjlink_class in PJLINK_VALID_CMD and cmd in PJLINK_VALID_CMD[self.pjlink_class]):
- log.warn('(%s) get_data(): Invalid packet - unknown command "%s"' % (self.ip, cmd))
+ log.warn('({}) get_data(): Invalid packet - unknown command "{}"'.format(self.ip, cmd))
self.send_busy = False
self.projectorReceivedData.emit()
return
@@ -429,7 +429,7 @@
:param err: Error code
"""
- log.debug('(%s) get_error(err=%s): %s' % (self.ip, err, self.errorString()))
+ log.debug('({}) get_error(err={}): {}'.format(self.ip, err, self.errorString()))
if err <= 18:
# QSocket errors. Redefined in projector.constants so we don't mistake
# them for system errors
@@ -458,32 +458,32 @@
:param queue: Option to force add to queue rather than sending directly
"""
if self.state() != self.ConnectedState:
- log.warn('(%s) send_command(): Not connected - returning' % self.ip)
+ log.warn('({}) send_command(): Not connected - returning'.format(self.ip))
self.send_queue = []
return
self.projectorNetwork.emit(S_NETWORK_SENDING)
- log.debug('(%s) send_command(): Building cmd="%s" opts="%s" %s' % (self.ip,
- cmd,
- opts,
- '' if salt is None else 'with hash'))
+ log.debug('({}) send_command(): Building cmd="{}" opts="{}" {}'.format(self.ip,
+ cmd,
+ opts,
+ '' if salt is None else 'with hash'))
if salt is None:
- out = '%s%s %s%s' % (PJLINK_HEADER, cmd, opts, CR)
+ out = '{}{} {}{}'.format(PJLINK_HEADER, cmd, opts, CR)
else:
- out = '%s%s%s %s%s' % (salt, PJLINK_HEADER, cmd, opts, CR)
+ out = '{}{}{} {}{}'.format(salt, PJLINK_HEADER, cmd, opts, CR)
if out in self.send_queue:
# Already there, so don't add
- log.debug('(%s) send_command(out="%s") Already in queue - skipping' % (self.ip, out.strip()))
+ log.debug('({}) send_command(out="{}") Already in queue - skipping'.format(self.ip, out.strip()))
elif not queue and len(self.send_queue) == 0:
# Nothing waiting to send, so just send it
- log.debug('(%s) send_command(out="%s") Sending data' % (self.ip, out.strip()))
+ log.debug('({}) send_command(out="{}") Sending data'.format(self.ip, out.strip()))
return self._send_command(data=out)
else:
- log.debug('(%s) send_command(out="%s") adding to queue' % (self.ip, out.strip()))
+ log.debug('({}) send_command(out="{}") adding to queue'.format(self.ip, out.strip()))
self.send_queue.append(out)
self.projectorReceivedData.emit()
- log.debug('(%s) send_command(): send_busy is %s' % (self.ip, self.send_busy))
+ log.debug('({}) send_command(): send_busy is {}'.format(self.ip, self.send_busy))
if not self.send_busy:
- log.debug('(%s) send_command() calling _send_string()')
+ log.debug('({}) send_command() calling _send_string()')
self._send_command()
@pyqtSlot()
@@ -493,10 +493,10 @@
:param data: Immediate data to send
"""
- log.debug('(%s) _send_string()' % self.ip)
- log.debug('(%s) _send_string(): Connection status: %s' % (self.ip, self.state()))
+ log.debug('({}) _send_string()'.format(self.ip))
+ log.debug('({}) _send_string(): Connection status: {}'.format(self.ip, self.state()))
if self.state() != self.ConnectedState:
- log.debug('(%s) _send_string() Not connected - abort' % self.ip)
+ log.debug('({}) _send_string() Not connected - abort'.format(self.ip))
self.send_queue = []
self.send_busy = False
return
@@ -505,18 +505,18 @@
return
if data is not None:
out = data
- log.debug('(%s) _send_string(data=%s)' % (self.ip, out.strip()))
+ log.debug('({}) _send_string(data={})'.format(self.ip, out.strip()))
elif len(self.send_queue) != 0:
out = self.send_queue.pop(0)
- log.debug('(%s) _send_string(queued data=%s)' % (self.ip, out.strip()))
+ log.debug('({}) _send_string(queued data={})'.format(self.ip, out.strip()))
else:
# No data to send
- log.debug('(%s) _send_string(): No data to send' % self.ip)
+ log.debug('({}) _send_string(): No data to send'.format(self.ip))
self.send_busy = False
return
self.send_busy = True
- log.debug('(%s) _send_string(): Sending "%s"' % (self.ip, out.strip()))
- log.debug('(%s) _send_string(): Queue = %s' % (self.ip, self.send_queue))
+ log.debug('({}) _send_string(): Sending "{}"'.format(self.ip, out.strip()))
+ log.debug('({}) _send_string(): Queue = {}'.format(self.ip, self.send_queue))
self.socket_timer.start()
try:
self.projectorNetwork.emit(S_NETWORK_SENDING)
@@ -528,7 +528,7 @@
translate('OpenLP.PJLink1', 'Error while sending data to projector'))
except SocketError as e:
self.disconnect_from_host(abort=True)
- self.changeStatus(E_NETWORK, '%s : %s' % (e.error(), e.errorString()))
+ self.changeStatus(E_NETWORK, '{} : {}'.format(e.error(), e.errorString()))
def process_command(self, cmd, data):
"""
@@ -537,18 +537,18 @@
:param cmd: Command to process
:param data: Data being processed
"""
- log.debug('(%s) Processing command "%s"' % (self.ip, cmd))
+ log.debug('({}) Processing command "{}"'.format(self.ip, cmd))
if data in PJLINK_ERRORS:
# Oops - projector error
if data.upper() == 'ERRA':
# Authentication error
self.disconnect_from_host()
self.change_status(E_AUTHENTICATION)
- log.debug('(%s) emitting projectorAuthentication() signal' % self.ip)
+ log.debug('({}) emitting projectorAuthentication() signal'.format(self.ip))
self.projectorAuthentication.emit(self.name)
elif data.upper() == 'ERR1':
# Undefined command
- self.change_status(E_UNDEFINED, '%s "%s"' %
+ self.change_status(E_UNDEFINED, '{} "{}"' %
(translate('OpenLP.PJLink1', 'Undefined command:'), cmd))
elif data.upper() == 'ERR2':
# Invalid parameter
@@ -564,7 +564,7 @@
return
# Command succeeded - no extra information
elif data.upper() == 'OK':
- log.debug('(%s) Command returned OK' % self.ip)
+ log.debug('({}) Command returned OK'.format(self.ip))
# A command returned successfully, recheck data
self.send_busy = False
self.projectorReceivedData.emit()
@@ -573,7 +573,7 @@
if cmd in self.PJLINK1_FUNC:
self.PJLINK1_FUNC[cmd](data)
else:
- log.warn('(%s) Invalid command %s' % (self.ip, cmd))
+ log.warn('({}) Invalid command {}'.format(self.ip, cmd))
self.send_busy = False
self.projectorReceivedData.emit()
@@ -592,7 +592,7 @@
fill = {'Hours': int(data_dict[0]), 'On': False if data_dict[1] == '0' else True}
except ValueError:
# In case of invalid entry
- log.warn('(%s) process_lamp(): Invalid data "%s"' % (self.ip, data))
+ log.warn('({}) process_lamp(): Invalid data "{}"'.format(self.ip, data))
return
lamps.append(fill)
data_dict.pop(0) # Remove lamp hours
@@ -619,7 +619,7 @@
self.send_command('INST')
else:
# Log unknown status response
- log.warn('Unknown power response: %s' % data)
+ log.warn('Unknown power response: {}'.format(data))
return
def process_avmt(self, data):
@@ -644,7 +644,7 @@
shutter = True
mute = True
else:
- log.warn('Unknown shutter response: %s' % data)
+ log.warn('Unknown shutter response: {}'.format(data))
update_icons = shutter != self.shutter
update_icons = update_icons or mute != self.mute
self.shutter = shutter
@@ -671,7 +671,7 @@
:param data: Class that projector supports.
"""
self.pjlink_class = data
- log.debug('(%s) Setting pjlink_class for this projector to "%s"' % (self.ip, self.pjlink_class))
+ log.debug('({}) Setting pjlink_class for this projector to "{}"'.format(self.ip, self.pjlink_class))
return
def process_name(self, data):
@@ -777,7 +777,7 @@
Initiate connection to projector.
"""
if self.state() == self.ConnectedState:
- log.warn('(%s) connect_to_host(): Already connected - returning' % self.ip)
+ log.warn('({}) connect_to_host(): Already connected - returning'.format(self.ip))
return
self.change_status(S_CONNECTING)
self.connectToHost(self.ip, self.port if type(self.port) is int else int(self.port))
@@ -789,9 +789,9 @@
"""
if abort or self.state() != self.ConnectedState:
if abort:
- log.warn('(%s) disconnect_from_host(): Aborting connection' % self.ip)
+ log.warn('({}) disconnect_from_host(): Aborting connection'.format(self.ip))
else:
- log.warn('(%s) disconnect_from_host(): Not connected - returning' % self.ip)
+ log.warn('({}) disconnect_from_host(): Not connected - returning'.format(self.ip))
self.reset_information()
self.disconnectFromHost()
try:
@@ -801,8 +801,8 @@
if abort:
self.change_status(E_NOT_CONNECTED)
else:
- log.debug('(%s) disconnect_from_host() Current status %s' % (self.ip,
- self._get_status(self.status_connect)[0]))
+ log.debug('({}) disconnect_from_host() Current status {}'.format(self.ip,
+ self._get_status(self.status_connect)[0]))
if self.status_connect != E_NOT_CONNECTED:
self.change_status(S_NOT_CONNECTED)
self.reset_information()
@@ -875,12 +875,12 @@
:param src: Video source to select in projector
"""
- log.debug('(%s) set_input_source(src=%s)' % (self.ip, src))
+ log.debug('({}) set_input_source(src={})'.format(self.ip, src))
if self.source_available is None:
return
elif src not in self.source_available:
return
- log.debug('(%s) Setting input source to %s' % (self.ip, src))
+ log.debug('({}) Setting input source to {}'.format(self.ip, src))
self.send_command(cmd='INPT', opts=src)
self.poll_loop()
=== modified file 'openlp/core/ui/projector/editform.py'
--- openlp/core/ui/projector/editform.py 2015-01-05 18:54:44 +0000
+++ openlp/core/ui/projector/editform.py 2015-01-15 20:46:09 +0000
@@ -190,9 +190,9 @@
QtGui.QMessageBox.warning(self,
translate('OpenLP.ProjectorEdit', 'Duplicate Name'),
translate('OpenLP.ProjectorEdit',
- 'There is already an entry with name "%s" in '
- 'the database as ID "%s". <br />'
- 'Please enter a different name.' % (name, record.id)))
+ 'There is already an entry with name "{}" in '
+ 'the database as ID "{}". <br />'
+ 'Please enter a different name.'.format(name, record.id)))
valid = False
return
adx = self.ip_text.text()
@@ -206,16 +206,17 @@
QtGui.QMessageBox.warning(self,
translate('OpenLP.ProjectorWizard', 'Duplicate IP Address'),
translate('OpenLP.ProjectorWizard',
- 'IP address "%s"<br />is already in the database as ID %s.'
- '<br /><br />Please Enter a different IP address.' % (adx, ip.id)))
+ 'IP address "{}"<br />is already in the database as ID {}.'
+ '<br /><br />Please Enter a different IP address.'.format(adx,
+ ip.id)))
valid = False
return
else:
QtGui.QMessageBox.warning(self,
translate('OpenLP.ProjectorWizard', 'Invalid IP Address'),
translate('OpenLP.ProjectorWizard',
- 'IP address "%s"<br>is not a valid IP address.'
- '<br /><br />Please enter a valid IP address.' % adx))
+ 'IP address "{}"<br>is not a valid IP address.'
+ '<br /><br />Please enter a valid IP address.'.format(adx)))
valid = False
return
port = int(self.port_text.text())
@@ -227,7 +228,7 @@
'<br />and port numbers above 32767 are not currently usable.'
'<br /><br />Please enter a valid port number between '
' 1000 and 32767.'
- '<br /><br />Default PJLink port is %s' % PJLINK_PORT))
+ '<br /><br />Default PJLink port is {}'.format(PJLINK_PORT)))
valid = False
if valid:
self.projector.ip = self.ip_text.text()
=== modified file 'openlp/core/ui/projector/manager.py'
--- openlp/core/ui/projector/manager.py 2015-01-04 17:38:59 +0000
+++ openlp/core/ui/projector/manager.py 2015-01-15 20:46:09 +0000
@@ -351,7 +351,7 @@
real_projector = item.data(QtCore.Qt.UserRole)
projector_name = str(item.text())
visible = real_projector.link.status_connect >= S_CONNECTED
- log.debug('(%s) Building menu - visible = %s' % (projector_name, visible))
+ log.debug('({}) Building menu - visible = {}'.format(projector_name, visible))
self.delete_action.setVisible(True)
self.edit_action.setVisible(True)
self.connect_action.setVisible(not visible)
@@ -401,7 +401,7 @@
projectordb=self.projectordb,
edit=edit)
source = source_select_form.exec_(projector.link)
- log.debug('(%s) source_select_form() returned %s' % (projector.link.ip, source))
+ log.debug('({}) source_select_form() returned {}'.format(projector.link.ip, source))
if source is not None and source > 0:
projector.link.set_input_source(str(source))
return
@@ -480,7 +480,7 @@
return
projector = list_item.data(QtCore.Qt.UserRole)
msg = QtGui.QMessageBox()
- msg.setText('Delete projector (%s) %s?' % (projector.link.ip, projector.link.name))
+ msg.setText('Delete projector ({}) {}?'.format(projector.link.ip, projector.link.name))
msg.setInformativeText('Are you sure you want to delete this projector?')
msg.setStandardButtons(msg.Cancel | msg.Ok)
msg.setDefaultButton(msg.Cancel)
@@ -528,7 +528,7 @@
list_item = None
deleted = self.projectordb.delete_projector(projector.db_item)
for item in self.projector_list:
- log.debug('New projector list - item: %s %s' % (item.link.ip, item.link.name))
+ log.debug('New projector list - item: {} {}'.format(item.link.ip, item.link.name))
def on_disconnect_projector(self, opt=None):
"""
@@ -633,53 +633,54 @@
"""
lwi = self.projector_list_widget.item(self.projector_list_widget.currentRow())
projector = lwi.data(QtCore.Qt.UserRole)
- message = '<b>%s</b>: %s<BR />' % (translate('OpenLP.ProjectorManager', 'Name'),
- projector.link.name)
- message = '%s<b>%s</b>: %s<br />' % (message, translate('OpenLP.ProjectorManager', 'IP'),
- projector.link.ip)
- message = '%s<b>%s</b>: %s<br />' % (message, translate('OpenLP.ProjectorManager', 'Port'),
- projector.link.port)
- message = '%s<b>%s</b>: %s<br />' % (message, translate('OpenLP.ProjectorManager', 'Notes'),
- projector.link.notes)
- message = '%s<hr /><br >' % message
+ message = '<b>{}</b>: {}<BR />'.format(translate('OpenLP.ProjectorManager', 'Name'),
+ projector.link.name)
+ message = '{}<b>{}</b>: {}<br />'.format(message, translate('OpenLP.ProjectorManager', 'IP'),
+ projector.link.ip)
+ message = '{}<b>{}</b>: {}<br />'.format(message, translate('OpenLP.ProjectorManager', 'Port'),
+ projector.link.port)
+ message = '{}<b>{}</b>: {}<br />'.format(message, translate('OpenLP.ProjectorManager', 'Notes'),
+ projector.link.notes)
+ message = '{}<hr /><br >'.format(message)
if projector.link.manufacturer is None:
- message = '%s%s' % (message, translate('OpenLP.ProjectorManager',
- 'Projector information not available at this time.'))
+ message = '{}{}'.format(message, translate('OpenLP.ProjectorManager',
+ 'Projector information not available at this time.'))
else:
- message = '%s<b>%s</b>: %s<BR />' % (message, translate('OpenLP.ProjectorManager', 'Projector Name'),
- projector.link.pjlink_name)
- message = '%s<b>%s</b>: %s<br />' % (message, translate('OpenLP.ProjectorManager', 'Manufacturer'),
- projector.link.manufacturer)
- message = '%s<b>%s</b>: %s<br />' % (message, translate('OpenLP.ProjectorManager', 'Model'),
- projector.link.model)
- message = '%s<b>%s</b>: %s<br /><br />' % (message, translate('OpenLP.ProjectorManager', 'Other info'),
- projector.link.other_info)
- message = '%s<b>%s</b>: %s<br />' % (message, translate('OpenLP.ProjectorManager', 'Power status'),
- ERROR_MSG[projector.link.power])
- message = '%s<b>%s</b>: %s<br />' % (message, translate('OpenLP.ProjectorManager', 'Shutter is'),
- translate('OpenLP.ProjectorManager', 'Closed')
- if projector.link.shutter else translate('OpenLP', 'Open'))
- message = '%s<b>%s</b>: %s<br />' % (message,
- translate('OpenLP.ProjectorManager', 'Current source input is'),
- projector.link.source)
+ message = '{}<b>{}</b>: {}<BR />'.format(message, translate('OpenLP.ProjectorManager', 'Projector Name'),
+ projector.link.pjlink_name)
+ message = '{}<b>{}</b>: {}<br />'.format(message, translate('OpenLP.ProjectorManager', 'Manufacturer'),
+ projector.link.manufacturer)
+ message = '{}<b>{}</b>: {}<br />'.format(message, translate('OpenLP.ProjectorManager', 'Model'),
+ projector.link.model)
+ message = '{}<b>{}</b>: {}<br /><br />'.format(message, translate('OpenLP.ProjectorManager', 'Other info'),
+ projector.link.other_info)
+ message = '{}<b>{}</b>: {}<br />'.format(message, translate('OpenLP.ProjectorManager', 'Power status'),
+ ERROR_MSG[projector.link.power])
+ message = '{}<b>{}</b>: {}<br />'.format(message, translate('OpenLP.ProjectorManager', 'Shutter is'),
+ translate('OpenLP.ProjectorManager', 'Closed')
+ if projector.link.shutter else translate('OpenLP', 'Open'))
+ message = '{}<b>{}</b>: {}<br />'.format(message,
+ translate('OpenLP.ProjectorManager', 'Current source input is'),
+ projector.link.source)
count = 1
for item in projector.link.lamp:
- message = '%s <b>%s %s</b> (%s) %s: %s<br />' % (message,
- translate('OpenLP.ProjectorManager', 'Lamp'),
- count,
- translate('OpenLP.ProjectorManager', 'On')
- if item['On']
- else translate('OpenLP.ProjectorManager', 'Off'),
- translate('OpenLP.ProjectorManager', 'Hours'),
- item['Hours'])
+ message = '{} <b>{} {}</b> ({}) {}: {}<br />'.format(message,
+ translate('OpenLP.ProjectorManager', 'Lamp'),
+ count,
+ translate('OpenLP.ProjectorManager', 'On')
+ if item['On']
+ else translate('OpenLP.ProjectorManager', 'Off'),
+ translate('OpenLP.ProjectorManager', 'Hours'),
+ item['Hours'])
count = count + 1
- message = '%s<hr /><br />' % message
+ message = '{}<hr /><br />'.format(message)
if projector.link.projector_errors is None:
- message = '%s%s' % (message, translate('OpenLP.ProjectorManager', 'No current errors or warnings'))
+ message = '{}{}'.format(message, translate('OpenLP.ProjectorManager', 'No current errors or warnings'))
else:
- message = '%s<b>%s</b>' % (message, translate('OpenLP.ProjectorManager', 'Current errors/warnings'))
+ message = '{}<b>{}</b>'.format(message, translate('OpenLP.ProjectorManager',
+ 'Current errors/warnings'))
for (key, val) in projector.link.projector_errors.items():
- message = '%s<b>%s</b>: %s<br />' % (message, key, ERROR_MSG[val])
+ message = '{}<b>{}</b>: {}<br />'.format(message, key, ERROR_MSG[val])
QtGui.QMessageBox.information(self, translate('OpenLP.ProjectorManager', 'Projector Information'), message)
def _add_projector(self, projector):
@@ -749,7 +750,7 @@
if start:
item.link.connect_to_host()
for item in self.projector_list:
- log.debug('New projector list - item: (%s) %s' % (item.link.ip, item.link.name))
+ log.debug('New projector list - item: ({}) {}'.format(item.link.ip, item.link.name))
@pyqtSlot(str)
def add_projector_from_wizard(self, ip, opts=None):
@@ -759,7 +760,7 @@
:param ip: IP address of new record item to find
:param opts: Needed by PyQt4
"""
- log.debug('add_projector_from_wizard(ip=%s)' % ip)
+ log.debug('add_projector_from_wizard(ip={})'.format(ip))
item = self.projectordb.get_projector_by_ip(ip)
self.add_projector(item)
@@ -770,7 +771,7 @@
:param projector: Projector() instance of projector with updated information
"""
- log.debug('edit_projector_from_wizard(ip=%s)' % projector.ip)
+ log.debug('edit_projector_from_wizard(ip={})'.format(projector.ip))
self.old_projector.link.name = projector.name
self.old_projector.link.ip = projector.ip
self.old_projector.link.pin = None if projector.pin == '' else projector.pin
@@ -822,7 +823,7 @@
else:
status_code = status
message = ERROR_MSG[status] if msg is None else msg
- log.debug('(%s) updateStatus(status=%s) message: "%s"' % (item.link.name, status_code, message))
+ log.debug('({}) updateStatus(status={}) message: "{}"'.format(item.link.name, status_code, message))
if status in STATUS_ICONS:
if item.status == status:
return
@@ -832,14 +833,14 @@
status_code = ERROR_STRING[status]
elif status in STATUS_STRING:
status_code = STATUS_STRING[status]
- log.debug('(%s) Updating icon with %s' % (item.link.name, status_code))
+ log.debug('({}) Updating icon with {}'.format(item.link.name, status_code))
item.widget.setIcon(item.icon)
self.update_icons()
def get_toolbar_item(self, name, enabled=False, hidden=False):
item = self.one_toolbar.findChild(QtGui.QAction, name)
if item == 0:
- log.debug('No item found with name "%s"' % name)
+ log.debug('No item found with name "{}"'.format(name))
return
item.setVisible(False if hidden else True)
item.setEnabled(True if enabled else False)
@@ -925,10 +926,10 @@
:param name: Name from QListWidgetItem
"""
QtGui.QMessageBox.warning(self, translate('OpenLP.ProjectorManager',
- '"%s" Authentication Error' % name),
+ '"{}" Authentication Error'.format(name)),
'<br />There was an authentication error while trying to connect.'
'<br /><br />Please verify your PIN setting '
- 'for projector item "%s"' % name)
+ 'for projector item "{}"'.format(name))
@pyqtSlot(str)
def no_authentication_error(self, name):
@@ -939,10 +940,10 @@
:param name: Name from QListWidgetItem
"""
QtGui.QMessageBox.warning(self, translate('OpenLP.ProjectorManager',
- '"%s" No Authentication Error' % name),
+ '"{}" No Authentication Error'.format(name)),
'<br />PIN is set and projector does not require authentication.'
'<br /><br />Please verify your PIN setting '
- 'for projector item "%s"' % name)
+ 'for projector item "{}"'.format(name))
class ProjectorItem(QObject):
@@ -978,5 +979,5 @@
QtGui.QMessageBox.information(None,
translate('OpenLP.ProjectorManager', 'Not Implemented Yet'),
translate('OpenLP.ProjectorManager',
- 'Function "%s"<br />has not been implemented yet.'
- '<br />Please check back again later.' % function))
+ 'Function "{}"<br />has not been implemented yet.'
+ '<br />Please check back again later.'.format(function)))
=== modified file 'openlp/core/ui/projector/sourceselectform.py'
--- openlp/core/ui/projector/sourceselectform.py 2014-12-31 10:58:13 +0000
+++ openlp/core/ui/projector/sourceselectform.py 2015-01-15 20:46:09 +0000
@@ -118,7 +118,7 @@
if edit:
for key in sourcelist:
item = QLineEdit()
- item.setObjectName('source_key_%s' % key)
+ item.setObjectName('source_key_{}'.format(key))
source_item = projectordb.get_source_by_code(code=key, projector_id=projector.db_item.id)
if source_item is None:
item.setText(PJLINK_DEFAULT_CODES[key])
@@ -339,8 +339,7 @@
msg = QtGui.QMessageBox()
msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector'))
msg.setInformativeText(translate('OpenLP.SourceSelectForm',
- 'Are you sure you want to delete ALL user-defined '),
- translate('OpenLP.SourceSelectForm',
+ 'Are you sure you want to delete ALL user-defined '
'source input text for this projector?'))
msg.setStandardButtons(msg.Cancel | msg.Ok)
msg.setDefaultButton(msg.Cancel)
@@ -363,16 +362,16 @@
continue
item = self.projectordb.get_source_by_code(code=code, projector_id=projector.id)
if item is None:
- log.debug("(%s) Adding new source text %s: %s" % (projector.ip, code, text))
+ log.debug("({}) Adding new source text {}: {}".format(projector.ip, code, text))
item = ProjectorSource(projector_id=projector.id, code=code, text=text)
else:
item.text = text
- log.debug('(%s) Updating source code %s with text="%s"' % (projector.ip, item.code, item.text))
+ log.debug('({}) Updating source code {} with text="{}"'.format(projector.ip, item.code, item.text))
self.projectordb.add_source(item)
selected = 0
else:
selected = self.button_group.checkedId()
- log.debug('SourceSelectTabs().accepted() Setting source to %s' % selected)
+ log.debug('SourceSelectTabs().accepted() Setting source to {}'.format(selected))
self.done(selected)
@@ -421,7 +420,7 @@
if self.edit:
for key in keys:
item = QLineEdit()
- item.setObjectName('source_key_%s' % key)
+ item.setObjectName('source_key_{}'.format(key))
source_item = self.projectordb.get_source_by_code(code=key, projector_id=self.projector.db_item.id)
if source_item is None:
item.setText(PJLINK_DEFAULT_CODES[key])
@@ -503,14 +502,14 @@
continue
item = self.projectordb.get_source_by_code(code=code, projector_id=projector.id)
if item is None:
- log.debug("(%s) Adding new source text %s: %s" % (projector.ip, code, text))
+ log.debug("({}) Adding new source text {}: {}".format(projector.ip, code, text))
item = ProjectorSource(projector_id=projector.id, code=code, text=text)
else:
item.text = text
- log.debug('(%s) Updating source code %s with text="%s"' % (projector.ip, item.code, item.text))
+ log.debug('({}) Updating source code {} with text="{}"'.format(projector.ip, item.code, item.text))
self.projectordb.add_source(item)
selected = 0
else:
selected = self.button_group.checkedId()
- log.debug('SourceSelectDialog().accepted() Setting source to %s' % selected)
+ log.debug('SourceSelectDialog().accepted() Setting source to {}'.format(selected))
self.done(selected)
Follow ups