Re: [Openlp-core] [Merge] lp:~alisonken1/openlp/pjlink2g into lp:openlp

2017-08-06 Thread Ken Roberts
Other than tests - there should be no new code here, only restructured code.
-- 
https://code.launchpad.net/~alisonken1/openlp/pjlink2g/+merge/328634
Your team OpenLP Core is requested to review the proposed merge of 
lp:~alisonken1/openlp/pjlink2g into lp:openlp.

___
Mailing list: https://launchpad.net/~openlp-core
Post to : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp


[Openlp-core] [Merge] lp:~alisonken1/openlp/pjlink2g into lp:openlp

2017-08-06 Thread Ken Roberts
Ken Roberts has proposed merging lp:~alisonken1/openlp/pjlink2g into lp:openlp.

Commit message:
PJLink2 update 

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/pjlink2g/+merge/328634

- Break PJLink class into base class and process commands class
- Restructure class methods
- Break projector PJLink tests into pjlink_base and pjlink_commands
- Restructure test methods
- Remove unused test imports
- Rename several tests
- Remove extraneous test (test_projector_return_ok)
- Added tests for process_erst reply


lp:~alisonken1/openlp/pjlink2g (revision 2756)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/2117/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/2027/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1935/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Code_Analysis/1312/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Test_Coverage/1155/
[SUCCESS] https://ci.openlp.io/job/Branch-04c-Code_Analysis2/285/
[SUCCESS] https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/130/

-- 
Your team OpenLP Core is requested to review the proposed merge of 
lp:~alisonken1/openlp/pjlink2g into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2017-05-20 05:51:58 +
+++ openlp/core/lib/__init__.py	2017-08-06 07:33:29 +
@@ -621,5 +621,5 @@
 from .renderer import Renderer
 from .mediamanageritem import MediaManagerItem
 from .projector.db import ProjectorDB, Projector
-from .projector.pjlink1 import PJLink
+from .projector.pjlink import PJLink
 from .projector.constants import PJLINK_PORT, ERROR_MSG, ERROR_STRING

=== modified file 'openlp/core/lib/projector/constants.py'
--- openlp/core/lib/projector/constants.py	2017-06-09 12:12:39 +
+++ openlp/core/lib/projector/constants.py	2017-08-06 07:33:29 +
@@ -154,7 +154,7 @@
  },
 'SRCH': {'version': ['2', ],
  'description': translate('OpenLP.PJLinkConstants',
-  'UDP broadcast search request for available projectors.')
+  'UDP broadcast search request for available projectors. Reply is ACKN.')
  },
 'SVER': {'version': ['2', ],
  'description': translate('OpenLP.PJLinkConstants',

=== renamed file 'openlp/core/lib/projector/pjlink1.py' => 'openlp/core/lib/projector/pjlink.py'
--- openlp/core/lib/projector/pjlink1.py	2017-07-20 15:31:50 +
+++ openlp/core/lib/projector/pjlink.py	2017-08-06 07:33:29 +
@@ -20,14 +20,17 @@
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA  #
 ###
 """
-:mod:`openlp.core.lib.projector.pjlink1` module
+:mod:`openlp.core.lib.projector.pjlink` module
 Provides the necessary functions for connecting to a PJLink-capable projector.
 
-See PJLink Class 1 Specifications for details.
-http://pjlink.jbmia.or.jp/english/dl.html
-
-Section 5-1 PJLink Specifications
-
+PJLink Class 1 Specifications.
+http://pjlink.jbmia.or.jp/english/dl_class1.html
+Section 5-1 PJLink Specifications
+Section 5-5 Guidelines for Input Terminals
+
+PJLink Class 2 Specifications.
+http://pjlink.jbmia.or.jp/english/dl_class2.html
+Section 5-1 PJLink Specifications
 Section 5-5 Guidelines for Input Terminals
 
 NOTE:
@@ -40,7 +43,7 @@
 import logging
 log = logging.getLogger(__name__)
 
-log.debug('pjlink1 loaded')
+log.debug('pjlink loaded')
 
 __all__ = ['PJLink']
 
@@ -69,7 +72,407 @@
 PJLINK_SUFFIX = CR
 
 
-class PJLink(QtNetwork.QTcpSocket):
+class PJLinkCommands(object):
+"""
+Process replies from PJLink projector.
+"""
+
+def __init__(self, *args, **kwargs):
+"""
+Setup for the process commands
+"""
+log.debug('PJlinkCommands(args={args} kwargs={kwargs})'.format(args=args, kwargs=kwargs))
+super().__init__()
+# Map command to function
+self.pjlink_functions = {
+'AVMT': self.process_avmt,
+'CLSS': self.process_clss,
+'ERST': self.process_erst,
+'INFO': self.process_info,
+'INF1': self.process_inf1,
+'INF2': self.process_inf2,
+'INPT': self.process_inpt,
+'INST': self.process_inst,
+'LAMP': self.process_lamp,
+'NAME': self.process_name,
+'PJLINK': self.check_login,
+'POWR': self.process_powr,
+'SNUM': self.process_snum,
+'SVER': self.process_sver,
+'RFIL': self.process_rfil,
+'RLMP': self.process_rlmp
+}
+
+def reset_information(self):
+"""
+Initialize instance variables. Also used to reset projector-specific information to default.
+"""
+log.debug('({ip}) reset_information() con

Re: [Openlp-core] [Merge] lp:~alisonken1/openlp/pjlink2g into lp:openlp

2017-08-06 Thread Tim Bentley
Review: Needs Fixing

Some comments on the code as we are improving it !

Diff comments:

> 
> === renamed file 'openlp/core/lib/projector/pjlink1.py' => 
> 'openlp/core/lib/projector/pjlink.py'
> --- openlp/core/lib/projector/pjlink1.py  2017-07-20 15:31:50 +
> +++ openlp/core/lib/projector/pjlink.py   2017-08-06 07:33:29 +
> @@ -69,7 +72,407 @@
>  PJLINK_SUFFIX = CR
>  
>  
> -class PJLink(QtNetwork.QTcpSocket):
> +class PJLinkCommands(object):
> +"""
> +Process replies from PJLink projector.
> +"""
> +
> +def __init__(self, *args, **kwargs):
> +"""
> +Setup for the process commands
> +"""
> +log.debug('PJlinkCommands(args={args} 
> kwargs={kwargs})'.format(args=args, kwargs=kwargs))
> +super().__init__()
> +# Map command to function
> +self.pjlink_functions = {
> +'AVMT': self.process_avmt,
> +'CLSS': self.process_clss,
> +'ERST': self.process_erst,
> +'INFO': self.process_info,
> +'INF1': self.process_inf1,
> +'INF2': self.process_inf2,
> +'INPT': self.process_inpt,
> +'INST': self.process_inst,
> +'LAMP': self.process_lamp,
> +'NAME': self.process_name,
> +'PJLINK': self.check_login,
> +'POWR': self.process_powr,
> +'SNUM': self.process_snum,
> +'SVER': self.process_sver,
> +'RFIL': self.process_rfil,
> +'RLMP': self.process_rlmp
> +}
> +
> +def reset_information(self):
> +"""
> +Initialize instance variables. Also used to reset projector-specific 
> information to default.
> +"""
> +log.debug('({ip}) reset_information() connect status is 
> {state}'.format(ip=self.ip, state=self.state()))
> +self.fan = None  # ERST
> +self.filter_time = None  # FILT
> +self.lamp = None  # LAMP
> +self.mac_adx_received = None  # ACKN
> +self.manufacturer = None  # INF1
> +self.model = None  # INF2
> +self.model_filter = None  # RFIL
> +self.model_lamp = None  # RLMP
> +self.mute = None  # AVMT
> +self.other_info = None  # INFO
> +self.pjlink_class = PJLINK_CLASS  # Default class
> +self.pjlink_name = None  # NAME
> +self.power = S_OFF  # POWR
> +self.serial_no = None  # SNUM
> +self.serial_no_received = None
> +self.sw_version = None  # SVER
> +self.sw_version_received = None
> +self.shutter = None  # AVMT
> +self.source_available = None  # INST
> +self.source = None  # INPT
> +# These should be part of PJLink() class, but set here for 
> convenience
> +if hasattr(self, 'timer'):
> +log.debug('({ip}): Calling timer.stop()'.format(ip=self.ip))
> +self.timer.stop()
> +if hasattr(self, 'socket_timer'):
> +log.debug('({ip}): Calling 
> socket_timer.stop()'.format(ip=self.ip))
> +self.socket_timer.stop()
> +self.send_busy = False
> +self.send_queue = []
> +
> +def process_command(self, cmd, data):
> +"""
> +Verifies any return error code. Calls the appropriate command 
> handler.
> +
> +:param cmd: Command to process
> +:param data: Data being processed
> +"""
> +log.debug('({ip}) Processing command "{cmd}" with data 
> "{data}"'.format(ip=self.ip,
> + 
>cmd=cmd,
> + 
>data=data))
> +# Check if we have a future command not available yet
> +if cmd not in PJLINK_VALID_CMD:
> +log.error("({ip}) Ignoring command='{cmd}' 
> (Invalid/Unknown)".format(ip=self.ip, cmd=cmd))
> +return
> +elif cmd not in self.pjlink_functions:
> +log.warn("({ip}) Unable to process command='{cmd}' (Future 
> option)".format(ip=self.ip, cmd=cmd))
> +return
> +elif data in PJLINK_ERRORS:
> +# Oops - projector error
> +log.error('({ip}) Projector returned error 
> "{data}"'.format(ip=self.ip, data=data))
> +if data.upper() == 'ERRA':

Would not _data = data.upper() be better then test _data.

> +# Authentication error
> +self.disconnect_from_host()
> +self.change_status(E_AUTHENTICATION)
> +log.debug('({ip}) emitting projectorAuthentication() 
> signal'.format(ip=self.ip))
> +self.projectorAuthentication.emit(self.name)
> +elif data.upper() == 'ERR1':
> +# Undefined command
> +self.change_status(E_UNDEFINED, '{error}: 
> "{data}"'.format(error=ERROR_MSG[E_UNDEFINED],
> +   
> da

[Openlp-core] [Merge] lp:~alisonken1/openlp/pjlink2g into lp:openlp

2017-08-06 Thread Ken Roberts
The proposal to merge lp:~alisonken1/openlp/pjlink2g into lp:openlp has been 
updated.

Status: Needs review => Superseded

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/pjlink2g/+merge/328634
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.

___
Mailing list: https://launchpad.net/~openlp-core
Post to : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp


[Openlp-core] [Merge] lp:~alisonken1/openlp/pjlink2g into lp:openlp

2017-08-06 Thread Ken Roberts
Ken Roberts has proposed merging lp:~alisonken1/openlp/pjlink2g into lp:openlp.

Commit message:
PJLink2 update  G

Requested reviews:
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/pjlink2g/+merge/328640

- Break PJLink class into base class and process commands class
- Restructure class methods
- Break projector PJLink tests into pjlink_base and pjlink_commands
- Restructure test methods
- Remove unused test imports
- Rename several tests
- Remove extraneous test (test_projector_return_ok)
- Added tests for process_erst reply

So much for no code changes this update :).
- Convert AVMT check to use dict instead of if..elif
- Fix AVMT test


lp:~alisonken1/openlp/pjlink2g (revision 2758)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/2119/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/2029/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1936/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Code_Analysis/1313/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Test_Coverage/1156/
[SUCCESS] https://ci.openlp.io/job/Branch-04c-Code_Analysis2/286/
[SUCCESS] https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/131/

-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2017-05-20 05:51:58 +
+++ openlp/core/lib/__init__.py	2017-08-07 00:18:34 +
@@ -621,5 +621,5 @@
 from .renderer import Renderer
 from .mediamanageritem import MediaManagerItem
 from .projector.db import ProjectorDB, Projector
-from .projector.pjlink1 import PJLink
+from .projector.pjlink import PJLink
 from .projector.constants import PJLINK_PORT, ERROR_MSG, ERROR_STRING

=== modified file 'openlp/core/lib/projector/constants.py'
--- openlp/core/lib/projector/constants.py	2017-06-09 12:12:39 +
+++ openlp/core/lib/projector/constants.py	2017-08-07 00:18:34 +
@@ -154,7 +154,7 @@
  },
 'SRCH': {'version': ['2', ],
  'description': translate('OpenLP.PJLinkConstants',
-  'UDP broadcast search request for available projectors.')
+  'UDP broadcast search request for available projectors. Reply is ACKN.')
  },
 'SVER': {'version': ['2', ],
  'description': translate('OpenLP.PJLinkConstants',

=== renamed file 'openlp/core/lib/projector/pjlink1.py' => 'openlp/core/lib/projector/pjlink.py'
--- openlp/core/lib/projector/pjlink1.py	2017-07-20 15:31:50 +
+++ openlp/core/lib/projector/pjlink.py	2017-08-07 00:18:34 +
@@ -20,14 +20,17 @@
 # Temple Place, Suite 330, Boston, MA 02111-1307 USA  #
 ###
 """
-:mod:`openlp.core.lib.projector.pjlink1` module
+:mod:`openlp.core.lib.projector.pjlink` module
 Provides the necessary functions for connecting to a PJLink-capable projector.
 
-See PJLink Class 1 Specifications for details.
-http://pjlink.jbmia.or.jp/english/dl.html
-
-Section 5-1 PJLink Specifications
-
+PJLink Class 1 Specifications.
+http://pjlink.jbmia.or.jp/english/dl_class1.html
+Section 5-1 PJLink Specifications
+Section 5-5 Guidelines for Input Terminals
+
+PJLink Class 2 Specifications.
+http://pjlink.jbmia.or.jp/english/dl_class2.html
+Section 5-1 PJLink Specifications
 Section 5-5 Guidelines for Input Terminals
 
 NOTE:
@@ -40,7 +43,7 @@
 import logging
 log = logging.getLogger(__name__)
 
-log.debug('pjlink1 loaded')
+log.debug('pjlink loaded')
 
 __all__ = ['PJLink']
 
@@ -69,7 +72,403 @@
 PJLINK_SUFFIX = CR
 
 
-class PJLink(QtNetwork.QTcpSocket):
+class PJLinkCommands(object):
+"""
+Process replies from PJLink projector.
+"""
+
+def __init__(self, *args, **kwargs):
+"""
+Setup for the process commands
+"""
+log.debug('PJlinkCommands(args={args} kwargs={kwargs})'.format(args=args, kwargs=kwargs))
+super().__init__()
+# Map command to function
+self.pjlink_functions = {
+'AVMT': self.process_avmt,
+'CLSS': self.process_clss,
+'ERST': self.process_erst,
+'INFO': self.process_info,
+'INF1': self.process_inf1,
+'INF2': self.process_inf2,
+'INPT': self.process_inpt,
+'INST': self.process_inst,
+'LAMP': self.process_lamp,
+'NAME': self.process_name,
+'PJLINK': self.check_login,
+'POWR': self.process_powr,
+'SNUM': self.process_snum,
+'SVER': self.process_sver,
+'RFIL': self.process_rfil,
+'RLMP': self.process_rlmp
+}
+
+def reset_information(self):
+"""
+Initialize instance variables. Also used to reset projector-specific information to default.
+"