1787 # Get connector from uri |
1787 # Get connector from uri |
1788 try: |
1788 try: |
1789 self._SetConnector(connectors.ConnectorFactory(uri, self)) |
1789 self._SetConnector(connectors.ConnectorFactory(uri, self)) |
1790 except Exception as e: |
1790 except Exception as e: |
1791 self.logger.write_error( |
1791 self.logger.write_error( |
1792 _("Exception while connecting to '%s': %s\n") % (uri, str(e))) |
1792 _("Exception while connecting to '{uri}': {ex}\n").format( |
1793 #self.logger.write_error(traceback.format_exc()) |
1793 uri=uri, ex=e)) |
1794 |
1794 |
1795 # Did connection success ? |
1795 # Did connection success ? |
1796 if self._connector is None: |
1796 if self._connector is None: |
1797 # Oups. |
1797 # Oups. |
1798 self.logger.write_error(_("Connection failed to %s!\n") % uri) |
1798 self.logger.write_error(_("Connection failed to %s!\n") % uri) |
1811 |
1811 |
1812 def CompareLocalAndRemotePLC(self): |
1812 def CompareLocalAndRemotePLC(self): |
1813 if self._connector is None: |
1813 if self._connector is None: |
1814 return |
1814 return |
1815 builder = self.GetBuilder() |
1815 builder = self.GetBuilder() |
1816 if builder is None : |
1816 if builder is None: |
1817 return |
1817 return |
1818 MD5 = builder.GetBinaryMD5() |
1818 MD5 = builder.GetBinaryMD5() |
1819 if MD5 is None: |
1819 if MD5 is None: |
1820 return |
1820 return |
1821 # Check remote target PLC correspondance to that md5 |
1821 # Check remote target PLC correspondance to that md5 |
1844 builder = self.GetBuilder() |
1844 builder = self.GetBuilder() |
1845 if builder is None: |
1845 if builder is None: |
1846 self.logger.write_error(_("Fatal : cannot get builder.\n")) |
1846 self.logger.write_error(_("Fatal : cannot get builder.\n")) |
1847 return False |
1847 return False |
1848 |
1848 |
1849 # recover md5 from last build |
1849 # recover md5 from last build |
1850 MD5 = builder.GetBinaryMD5() |
1850 MD5 = builder.GetBinaryMD5() |
1851 |
1851 |
1852 # Check if md5 file is empty : ask user to build PLC |
1852 # Check if md5 file is empty : ask user to build PLC |
1853 if MD5 is None: |
1853 if MD5 is None: |
1854 self.logger.write_error( |
1854 self.logger.write_error( |
1869 for extrafilespath in [self._getExtraFilesPath(), |
1869 for extrafilespath in [self._getExtraFilesPath(), |
1870 self._getProjectFilesPath()]: |
1870 self._getProjectFilesPath()]: |
1871 |
1871 |
1872 for name in os.listdir(extrafilespath): |
1872 for name in os.listdir(extrafilespath): |
1873 extrafiles.append(( |
1873 extrafiles.append(( |
1874 name, |
1874 name, |
1875 self._connector.BlobFromFile( |
1875 self._connector.BlobFromFile( |
1876 # use file name as a seed to avoid collisions |
1876 # use file name as a seed to avoid collisions |
1877 # with files having same content |
1877 # with files having same content |
1878 os.path.join(extrafilespath, name),name))) |
1878 os.path.join(extrafilespath, name), name))) |
1879 |
1879 |
1880 # Send PLC on target |
1880 # Send PLC on target |
1881 object_path = builder.GetBinaryPath() |
1881 object_path = builder.GetBinaryPath() |
1882 # arbitrarily use MD5 as a seed, could be any string |
1882 # arbitrarily use MD5 as a seed, could be any string |
1883 object_blob = self._connector.BlobFromFile(object_path, MD5) |
1883 object_blob = self._connector.BlobFromFile(object_path, MD5) |