#6 Add patches that fix collaboration failure, patches will be removed when
Merged 2 years ago by pbrobinson. Opened 2 years ago by chimosky.
rpms/ chimosky/sugar dev  into  master

@@ -0,0 +1,42 @@ 

+ From 03c464355460df668631feb0fa7a70c1499306aa Mon Sep 17 00:00:00 2001

+ From: James Cameron <quozl@laptop.org>

+ Date: Sat, 2 May 2020 11:38:57 +1000

+ Subject: [PATCH] Fix DBusException using Moon activity

+ 

+ Moon activity makes multiple datastore API calls within one second, and

+ the file used to store the data is named by the second of the epoch,

+ such that one API call clashes with another.

+ 

+ Use a sequence number instead of the second of the epoch.

+ ---

+  src/jarabe/apisocket.py | 5 +++--

+  1 file changed, 3 insertions(+), 2 deletions(-)

+ 

+ diff --git a/src/jarabe/apisocket.py b/src/jarabe/apisocket.py

+ index fc4561716..bcefedf2e 100644

+ --- a/src/jarabe/apisocket.py

+ +++ b/src/jarabe/apisocket.py

+ @@ -16,7 +16,6 @@

+  import json

+  import os

+  import struct

+ -import time

+  import binascii

+  

+  import dbus

+ @@ -115,12 +114,14 @@ def __init__(self, client):

+                                      "/org/laptop/sugar/DataStore")

+          self._data_store = dbus.Interface(bus_object,

+                                            "org.laptop.sugar.DataStore")

+ +        self._sequence = 0

+  

+      def _create_file(self):

+          activity_root = env.get_profile_path(self._activity.get_type())

+          instance_path = os.path.join(activity_root, "instance")

+  

+ -        file_path = os.path.join(instance_path, "%i" % time.time())

+ +        self._sequence += 1

+ +        file_path = os.path.join(instance_path, "%d" % self._sequence)

+          file_object = open(file_path, "w")

+  

+          return file_path, file_object

@@ -0,0 +1,97 @@ 

+ From f1ac68488631ab153dd31b737819fd5cadc3b158 Mon Sep 17 00:00:00 2001

+ From: Shaan Subbaiah <shaansubbaiah.cs18@bmsce.ac.in>

+ Date: Sat, 14 Mar 2020 21:13:40 +0530

+ Subject: [PATCH] Port to Python 3 - API Socket

+ 

+ When Gears loads a saved journal object, no gears are shown, and Sugar

+ shell.log contains;

+ 

+ Traceback (most recent call last):

+   File "jarabe/apisocket.py", line 327, in _message_received_cb

+     stream_id = ord(message.data[0])

+ TypeError: ord() expected string of length 1, but int found

+ 

+ Comparing the type of data between Sugar Live Build with Sugar 0.117

+ running Python 3 and OLPC OS 18.04 running Python 2:

+ 

+ (1) Python 3, stream_id type is int

+ 

+ (2) Python 2, stream_id type is str

+ ` Type of streamid: <type 'str'> `

+ ` Ord(stream_id) type: <type 'int'> `

+ 

+ stream_id is supposed to be an Int, ord() is not required in Python 3 as

+ it was in Python 2, as indexing a bytes buffer yields a string.  In

+ Python 3 it yields an integer.

+ 

+ Also, for data loaded at DatastoreAPI.save.on_data :

+ 

+ (1) Python 3, data type is bytes

+ ` DatastoreAPI.save.on_data(data), data of type: <class 'bytes'> `

+ ` data[1:].decode('utf-8') of type:<class 'str'> `

+ 

+ (2) Python 2, data type is str

+ ` DatastoreAPI.save.on_data(data), data of type: <type 'str'> `

+ 

+ write() function requires parameter of type str because file is text.

+ In Python 2 the bytes type is the same as the str type.  So write() had

+ no issues with Python 2.

+ 

+ The commit fixes these and data from the Journal loads properly.

+ Read and write data in binary, so as to avoid conversion to text.

+ Activity data can be saved and resumed, no issues logged.

+ 

+ Related to

+ https://github.com/sugarlabs/sugar/issues/909

+ 

+ Part of

+ https://github.com/sugarlabs/sugar/pull/911

+ 

+ Regression introduced

+ aa18879e9717dfe2d30f249549e9a43d6dd6da4f

+ 

+ Signed-off-by: James Cameron <quozl@laptop.org>

+ ---

+  src/jarabe/apisocket.py | 8 ++++----

+  1 file changed, 4 insertions(+), 4 deletions(-)

+ 

+ diff --git a/src/jarabe/apisocket.py b/src/jarabe/apisocket.py

+ index bcefedf2e..a15376811 100644

+ --- a/src/jarabe/apisocket.py

+ +++ b/src/jarabe/apisocket.py

+ @@ -122,7 +122,7 @@ def _create_file(self):

+  

+          self._sequence += 1

+          file_path = os.path.join(instance_path, "%d" % self._sequence)

+ -        file_object = open(file_path, "w")

+ +        file_object = open(file_path, "wb")

+  

+          return file_path, file_object

+  

+ @@ -153,7 +153,7 @@ def error_handler(error):

+  

+      def load(self, request):

+          def get_filename_reply_handler(file_name):

+ -            file_object = open(file_name)

+ +            file_object = open(file_name, 'rb')

+              info["file_object"] = file_object

+  

+              if "requested_size" in info:

+ @@ -169,7 +169,7 @@ def error_handler(error):

+              self._client.send_error(request, error)

+  

+          def send_binary(data):

+ -            self._client.send_binary(chr(stream_id) + data)

+ +            self._client.send_binary(bytes([stream_id]) + data)

+  

+          def on_data(data):

+              size = struct.unpack("ii", data)[1]

+ @@ -324,7 +324,7 @@ def _session_started_cb(self, server, session):

+  

+      def _message_received_cb(self, session, message, client):

+          if message.message_type == Message.TYPE_BINARY:

+ -            stream_id = ord(message.data[0])

+ +            stream_id = message.data[0]

+              stream_monitor = client.stream_monitors[stream_id]

+              stream_monitor.on_data(message.data)

+              return

file modified
+7 -1
@@ -1,6 +1,6 @@ 

  Name:    sugar

  Version: 0.116

- Release: 9%{?dist}

+ Release: 10%{?dist}

  Summary: Constructionist learning platform

  URL:     http://sugarlabs.org/

  License: GPLv2+
@@ -11,6 +11,8 @@ 

  Patch1:  sugar-0.116-config-empy-fix.patch

  Patch2:  Port-to-Python-3-Adhoc-SSID-handling.patch

  Patch3:  sugar-fix-hang-on-make.patch

+ Patch4:  fix-dbus-exception-using-moon-activity.patch

+ Patch5:  port-to-python-3-API-Socket.patch

  

  BuildRequires: make

  BuildRequires: gcc
@@ -240,6 +242,10 @@ 

  %{_datadir}/sugar/extensions/cpsection/webaccount

  

  %changelog

+ * Thu Jan 21 2021 Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com> - 0.116-10

+ - Add patches that fix collaboration failure, patches will be removed when

+   package is updated to 0.118.

+ 

  * Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.116-9

  - Second attempt - Rebuilt for

    https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

@aperezbios this addresses the collaboration failure and the patches will be removed when the package is updated to 0.118.
@pbrobinson kindly review.

Pull-Request has been merged by pbrobinson

2 years ago