Previews in Medicines lens not displaying as expected

Bug #1094107 reported by Happy R
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
One Hundred Scopes
Incomplete
Undecided
Mark Tully

Bug Description

Hi!

Sorry for posting it here! (feel free to delete it)
I see on your Google+ page that you have updated the Medicines lens with interesting stuff, but unfortunately it doesn't seem to fully work.

The lens is usable but the previews are not appearing/working, tested on Ubuntu 12.10 and Ubuntu 13.04

in terminal this is the error, for /usr/lib/unity-lens-medicines/unity-medicines-daemon)

Traceback (most recent call last):
  File "/usr/lib/unity-lens-medicines/unity-medicines-daemon", line 274, in preview_uri
    link = tree.xpath("//table[@class='infobox']")[0]
IndexError: list index out of range
Traceback (most recent call last):
  File "/usr/lib/unity-lens-medicines/unity-medicines-daemon", line 274, in preview_uri
    link = tree.xpath("//table[@class='infobox']")[0]
IndexError: list index out of range
Traceback (most recent call last):
  File "/usr/lib/unity-lens-medicines/unity-medicines-daemon", line 274, in preview_uri
    link = tree.xpath("//table[@class='infobox']")[0]
IndexError: list index out of range

Tags: medicines
Revision history for this message
Mark Tully (markjtully) wrote :

The error indicates a problem parsing the wikipedia page with the drug information on it. Does this occur for all results or just for some? Can you give me an example of a search term that causes this to occur so that I can reproduce it?

The solution is probably a putting try: except: around the whole section which would leave the preview blank, but at least not throw an exception. Not all drugs have a wikipedia page and some have one, but without the infobox that the lens is parsing. This is an unavoidable drawback of using a freely editable source for data.

Revision history for this message
Happy R (razz-dulce) wrote :

The lens works fine (shows results, is fast, etc), clicking on a PIL downloads it in Evince.

Yet, right-clicking on it (for previews) doesn't work.

Yes, I've tried with search term like "a", "losec", "omep", "panadol" (including the term you have posted the preview with it, on your Google+ page).

I waited for couple of minutes, too, to show the preview.

Revision history for this message
Mark Tully (markjtully) wrote :

I can't reproduce this at all. Every search I try produces the preview as expected. So, to help try to figure out the problem, I've pushed a change to the version in ppa:markjtully/ppa.

Now, when run from the command line, and there is a problem when the preview tries to parse the wikipedia page, the first 5000 characters of the body of that page will be printed in the terminal along with the url it is accessing. Could you try previewing a result with this version and post what it prints in the terminal?

Note that this version (0.4-0~12) is only being added to my PPA and not the 100 Scopes one.

affects: unity-web-history-lens → onehundredscopes
tags: added: medicines
Changed in onehundredscopes:
assignee: nobody → Mark Tully (markjtully)
status: New → Incomplete
summary: - Unity Medicines lens related
+ Previews in Medicines lens not displaying as expected
Revision history for this message
Happy R (razz-dulce) wrote :
Download full text (5.0 KiB)

I followed your steps and here it is

http://en.wikipedia.org/wiki/Calcium
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Calcium skin-vector action-view vector-animateLayout">
  <div id="mw-page-base" class="noprint"></div>
  <div id="mw-head-base" class="noprint"></div>
  <!-- content -->
  <div id="content" class="mw-body" role="main">
   <a id="top"></a>
   <div id="mw-js-message" style="display:none;"></div>
      <!-- sitenotice -->
   <div id="siteNotice"><!-- CentralNotice --><script>
 mw.loader.using( 'ext.centralNotice.bannerController', function() { mw.centralNotice.initialize(); } );
</script></div>
   <!-- /sitenotice -->
      <!-- firstHeading -->
   <h1 id="firstHeading" class="firstHeading" lang="en"><span dir="auto">Calcium</span></h1>
   <!-- /firstHeading -->
   <!-- bodyContent -->
   <div id="bodyContent">
        <!-- tagline -->
    <div id="siteSub">From Wikipedia, the free encyclopedia</div>
    <!-- /tagline -->
        <!-- subtitle -->
    <div id="contentSub"></div>
    <!-- /subtitle -->
          <!-- jumpto -->
    <div id="jump-to-nav" class="mw-jump">
     Jump to: <a href="#mw-head">navigation</a>, <a href="#p-search">search</a>
    </div>
    <!-- /jumpto -->
        <!-- bodycontent -->
    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="dablink">This article is about the metallic element. For the place, see <a href="/wiki/Calcium,_New_York" title="Calcium, New York">Calcium, New York</a>.</div>
<div class="metadata topicon" id="protected-icon" style="display:none; right:55px;"><a href="/wiki/Wikipedia:Protection_policy#semi" title="This article is semi-protected due to vandalism."><img alt="Page semi-protected" src="//upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/20px-Padlock-silver.svg.png" width="20" height="20" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/30px-Padlock-silver.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/40px-Padlock-silver.svg.png 2x"></a></div>
<table class="infobox bordered" cellpadding="2" cellspacing="0" style="font-size:88%; width:22em; text-align:left"><tr><th colspan="2" style="font-size:130%; text-align:center; background-color:#FFDEAD; color:#000000;">Calcium</th>
</tr><tr><td colspan="2">
<div title="atomic number Z=20; symbol=Ca" style="text-align:center; border:none; font-size:130%;"><b><sub><span style="font-size:smaller">20</span></sub>Ca</b></div>
</td>
</tr><tr><td colspan="2">
<table width="100%" cellspacing="0" cellpadding="0" border="1" style="text-align:center; padding-top:2px;"><tr><td style="width:10px; vertical-align:middle; border:none; font-size:88%; line-height:100%; padding:2px;"><a href="/wiki/Magnesium" title="Magnesium">Mg</a><br>
&#8593;<br><span style="font-size:110%; line-height:110%;"><b>Ca</b></span><br>
&#8595;<br><a href="/wiki/Strontium" title="Strontium">Sr</a></td>
<td style="border:none">
<table cellspacing="0" cellpadding="0" border="0" style="border:none;"><tr><td style="width:10px; border:none; padding:0; margin:0;">
<div style="position:relative; border:none">
<table class="nogrid" cellpaddi...

Read more...

Revision history for this message
Mark Tully (markjtully) wrote :

Your result shows that the lens is seeing the wikipedia page correctly. Unfortunately, you have chosen a result that wouldn't show a correct preview in any case. You've searched for something where the first word of the drug entity is 'Calcium', which does not have the infobox we're looking for on its wikipedia page.

Currently, the preview works by taking the first word of the drug name of the result (e.g. for Losec I.V. Injection 40mg, it takes the word 'Omeprazole', but for something where the drug name is something like 'Calcium Carbonate', it would just look up 'Calcium') This could be a bit more flexible.

Could you try the same thing again using a specific search. Type 'Losec' into the lens and 'Losec I.V. injection 40mg' should be among the results. Could you post the same thing as last time for that result and also include a screenshot of the preview, if possible. (the 'prt sc' key on the keyboard should allow you to take a screenshot without having to open special programs to do so)

Revision history for this message
Happy R (razz-dulce) wrote :

Hi and thanks for your patience!

For "losec" the 5000 characters don't appear anymore!

The 5000 characters appear only on certain icons/items, after I right-click on 20, 30 results, I can't reproduce it in less than 20 minutes.

After 10, 15 minutes of trying, the lens starts to repeat the error multiple times, the same error.

Usually, right-clicking on icons doesn't do anything in the terminal, only shows "search changed to"

I've attached an image!

Revision history for this message
Mark Tully (markjtully) wrote :

Could you please attach a screenshot displaying the actual preview which is displayed when you right click on the 'Losec I.V. Injection 40mg" results in the previous screenshot? I've uploaded a new version (0.4-0~13) which should output to the terminal whether the preview fails or not (the last one only did when it failed). So, also any output in the terminal which is printed when you activate the preview.

Revision history for this message
Happy R (razz-dulce) wrote :
Download full text (5.2 KiB)

I would gladly add a screenshot of the preview, but it doesn't give a preview when I right-click on a file.

Here is the output (after right-clicking on "Losec IV 40 mg")
The same behavior applies to the Academic lens, I've seen you added previews for Pubmed.
Hope it helps!

Search changed to: 'losec'
http://en.wikipedia.org/wiki/Omeprazole
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Omeprazole skin-vector action-view vector-animateLayout">
  <div id="mw-page-base" class="noprint"></div>
  <div id="mw-head-base" class="noprint"></div>
  <!-- content -->
  <div id="content" class="mw-body" role="main">
   <a id="top"></a>
   <div id="mw-js-message" style="display:none;"></div>
      <!-- sitenotice -->
   <div id="siteNotice"><!-- CentralNotice --><script>
 mw.loader.using( 'ext.centralNotice.bannerController', function() { mw.centralNotice.initialize(); } );
</script></div>
   <!-- /sitenotice -->
      <!-- firstHeading -->
   <h1 id="firstHeading" class="firstHeading" lang="en"><span dir="auto">Omeprazole</span></h1>
   <!-- /firstHeading -->
   <!-- bodyContent -->
   <div id="bodyContent">
        <!-- tagline -->
    <div id="siteSub">From Wikipedia, the free encyclopedia</div>
    <!-- /tagline -->
        <!-- subtitle -->
    <div id="contentSub"></div>
    <!-- /subtitle -->
          <!-- jumpto -->
    <div id="jump-to-nav" class="mw-jump">
     Jump to: <a href="#mw-head">navigation</a>, <a href="#p-search">search</a>
    </div>
    <!-- /jumpto -->
        <!-- bodycontent -->
    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><table class="infobox" style="width: 22em"><caption>Omeprazole</caption>
<tr><th colspan="2" style="text-align: center"><a href="/wiki/File:Omeprazole.svg" class="image"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/4/48/Omeprazole.svg/220px-Omeprazole.svg.png" width="220" height="94" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/4/48/Omeprazole.svg/330px-Omeprazole.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/4/48/Omeprazole.svg/440px-Omeprazole.svg.png 2x"></a></th>
</tr><tr><th colspan="2" style="text-align: center"><a href="/wiki/File:Omeprazole_3d_structure.png" class="image"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Omeprazole_3d_structure.png/220px-Omeprazole_3d_structure.png" width="220" height="163" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Omeprazole_3d_structure.png/330px-Omeprazole_3d_structure.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Omeprazole_3d_structure.png/440px-Omeprazole_3d_structure.png 2x"></a></th>
</tr><tr><th colspan="2" style="background-color: #ddd; text-align: center">Systematic (<a href="/wiki/International_Union_of_Pure_and_Applied_Chemistry_nomenclature" title="International Union of Pure and Applied Chemistry nomenclature" class="mw-redirect">IUPAC</a>) name</th>
</tr><tr><td colspan="2" style="text-align: center"><span style="font-size:11px">(<i>RS</i>)-5-methoxy-2-((4-methoxy-3,5-dimethylpyridin-2-yl) methylsulfinyl)-1<i>H</i>-benzo[<i>d</i>]imidazole</span></td>
</tr><tr><th colspan="2" style="background-color: #ddd; tex...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.