Nemo Plugin Error (Linux Mint 19.1)

Nemo 4.0.6 and insync-nemo-plugin is not working together:

root@yanx:~ apt install --reinstall insync-nemo
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 41,3 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://apt.insynchq.com/mint tara/contrib amd64 insync-nemo all 1.3.12.36116-precise [41,3 kB]
Fetched 41,3 kB in 0s (191 kB/s)     
(Reading database ... 433822 files and directories currently installed.)
Preparing to unpack .../insync-nemo_1.3.12.36116-precise_all.deb ...
Unpacking insync-nemo (1.3.12.36116-precise) over (1.3.12.36116-precise) ...
Setting up insync-nemo (1.3.12.36116-precise) ...
root@yanx:~# killall nemo
root@yanx:~# nemo -q
  File "/usr/share/nemo-python/extensions/insync-nemo-plugin.py", line 71
    print path
             ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(path)?
root@yanx:~# 

Tagging our engineer @Kurt_Ko for further assistance! :slight_smile:

Just posting to confirm that I get exactly the same error message with Mint 19.1. Up through Mint 19, insync-nemo worked fine.

1 Like

I have escalated this to our engineers and they’re currently working on the issue. We’ll make sure to update all affected users as soon as the fix has been deployed! :slight_smile:

Hi @Tobias_Schneck and @jpcusumano! Could you please run python --version and send the output here?

@mia sure.

$ python --version
Python 2.7.15rc1
$ python --version
Python 2.7.15rc1

I assume that’s what came with Mint 19.1?

yes:

$ cat /etc/os-release 
NAME="Linux Mint"
VERSION="19.1 (Tessa)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 19.1"
VERSION_ID="19.1"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.ubuntu.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=tessa
UBUNTU_CODENAME=bionic

Try putting this at /usr/share/nemo-python/extensions/insync-nemo-plugin.py:

print('loading insync nemo plugin..')
from gi.repository import GObject
from gi.repository import Nemo
import importlib
import traceback

DEV_MODE = False

import json
import os
import socket
import sys
import urllib.request, urllib.parse, urllib.error


if sys.getdefaultencoding() != 'utf-8':
  importlib.reload(sys)
  sys.setdefaultencoding('utf-8') # pylint: disable=E1101

def ipc_insync(**kw):
  if DEV_MODE:
    print('<ipc-insync>',kw)
  data = json.dumps( kw )
  socket_file = '/tmp/insync%r.sock' % os.getuid()
  if not os.path.exists(socket_file):
    if DEV_MODE:
      print('WARN: insync socket not found')
    return None
  sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
  sock.settimeout(0.5)
  try:
    sock.connect(socket_file)
    sock.send(data.encode())
    res = sock.recv(4096)
    sock.close()
  except:
    if DEV_MODE:
      traceback.print_exc()
    return None
  if res.strip():
    return json.loads(res.strip())
  else:
    if DEV_MODE:
      print("else")
    return None


_EMBLEM_KEYS = {
  'SYNCED': 'emblem-insync-synced',
  'SYNCING': 'emblem-insync-syncing',
  'ERROR': 'emblem-insync-error',
}


class InsyncMenuProvider(GObject.GObject, Nemo.MenuProvider, Nemo.InfoProvider):

  def __init__(self):
    self.file_list = dict()

  def get_background_items(self, window, file):
    return None

  def get_file_items(self, window, files):
    if DEV_MODE:
      print('get file items', files)

    if len(files) != 1:
      # TODO what can we do with mutiple files here
      return None

    file = files[0]
    if file.get_uri_scheme() != 'file':
      return None

    path = os.path.realpath(urllib.parse.unquote(file.get_uri()[len('file://'):]))
    path = str(path)
    if DEV_MODE:
      print(path)
    is_dir = os.path.isdir(path)

    cm_info = ipc_insync(command='CONTEXT-MENU-ITEMS', full_path=path)

    if cm_info:
      title, cm_items = cm_info
      tip = 'Insync folder actions' if is_dir else 'Insync file actions'
      item = Nemo.MenuItem(
        name='Insync:' + title,
        label=title,
        tip=tip,
        icon='insync'
      )
      sub_menu = Nemo.Menu()
      item.set_submenu(sub_menu)

      item_id = 0
      for text, cmd in cm_items:
        if text == 'separator':
          text = '\u2015' * 10
          name = 'Insync:separator:' + str(item_id)
        else:
          name = 'Insync:%s:%d' % (text, item_id)
        item_id += 1
        menu_item = Nemo.MenuItem(name=name, label=text, tip=text)
        if cmd:
          menu_item.connect('activate', self.do_action, file, cmd)
        else:
          menu_item.sensitive = False
        sub_menu.append_item(menu_item)

      return [item]
    return None

  def do_action(self, menu, file, method):
    path = urllib.parse.unquote(
      file.get_uri()[len('file://'):]
    )
    ipc_insync( method=method, full_path=path)

  def update_file_info(self, file):
    if file.get_uri_scheme() != 'file':
      return

    filename = urllib.parse.unquote(file.get_uri()[len('file://'):])
    filename = os.path.realpath(filename)
    status = ipc_insync(command='GET-FILE-STATUS', full_path=filename)
    if DEV_MODE:
      print("status", filename, status)
    if status and status != 'UNKNOWN':
      emblem = _EMBLEM_KEYS[status]
      if os.path.isdir(filename):
        is_shared = ipc_insync(command='IS-FILE-SHARED', full_path=filename)
        if is_shared:
          emblem += '-shared'
      file.add_emblem(emblem)
      old_emblem = self.file_list.get(filename)
      self.file_list[filename] = emblem
      if old_emblem != emblem:
        file.invalidate_extension_info()
    elif self.file_list.pop(filename, None):
      file.invalidate_extension_info()
4 Likes

I replaced the my file (10/5/16) with the text from pgmcgee, this fixed the problem.

The original insync-nemo-plugin.py file was installed by insync-nemo_1.3.12.36116-precise_all.deb.

Not sure it’s working perfectly, I only see the integration (to create to files for example) when right-clicking a folder or file. Nothing added to the menu when I right-click empty space below a folder in nemo.

1 Like

I haven’t given it an extensive workout, but I synched and unsynched a few things from the nemo context menu, and it seems to work!

Thanks, pgmgcee!

1 Like

The code fixed the problem so far I can see it. Thx for the help! Will the fix also be part of the next release?

Thanks a lot, it works! But a simple question : why not integrating this fix ASAP (= now) in the package?

1 Like

It works for me. Thanks.

Great, it works. Thanks!

It works for me, thanks!

Hallo Insync team. Are you going to solve the problem with nemo plugin? I know that there is workaround but Linux Mint is popular distribution and 19.1 version was released in December. Now there is the end of March and still there is no official solution.

Hi @Michal_L,

I completely understand your frustration on this.

Our Linux team is working hard on Insync 3 and may have overlooked this issue. I’ll let them know about this and see if there’s a fix we can deploy soon.

Thank you so much for the nudge on this, we appreciate it :heart:

It works now with the new version. But you need to download the debian package for nemo directly from the website https://www.insynchq.com/downloads

It would be good to include the package to the configured mint repo:
$ cat /etc/apt/sources.list.d/insync.list
deb http://apt.insync.io/mint tina non-free contrib