Re: OperatingSystem library and network share

929 views
Skip to first unread message

Bulkan

unread,
Oct 3, 2012, 7:36:34 AM10/3/12
to wayne....@wayju.com, robotframe...@googlegroups.com
Hi Wayne,

Try using this sort of quoting for the nextwork path

Count Files In Directory                  \\\\localhost${/}temp

Cheers


On Wed, Oct 3, 2012 at 1:59 PM, Wayne Thomson <wayne....@wayju.com> wrote:
Hi there,

We migrated a bunch of robot tests between machines and now a test which tries to access a network share fails. 

I can reproduce this locally with a simple test. Should I be able to do something like?

Count Files In Directory                  \\localhost\temp
or  
Count Files In Directory                   ${/}${/}localhost${/}temp

Note that I can reach this network share through the file browser, it runs as the same user, and it works with a local path.

 The only thing that I think could have changed when migrating would be the robot framework version (the shared path remains the same).

With much thanks,

Wayne.

--------------------------------------------------------------------------------------------------------------------------------

Report failure follows:

Status: FAIL (critical)
Message: Directory '\\localhost\temp' does not exist
+
KEYWORD: OperatingSystem.Count Files In Directory C:${/}shared-tempExpand All
+
KEYWORD: OperatingSystem.List Files In Directory C:${/}shared-tempExpand All
-
KEYWORD: OperatingSystem.Count Files In Directory ${/}${/}localhost${/}tempExpand All
Documentation:

A wrapper for `Count Items In Directory` returning only file count.

Start / End / Elapsed: 20121003 16:28:58.623 / 20121003 16:28:58.637 / 00:00:00.014
16:28:58.627INFOListing contents of directory '\\localhost\temp'.
16:28:58.636 FAILDirectory '\\localhost\temp' does not exist
+
TEARDOWN: Resources.Common Test Teardown 

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/robotframework-users/-/LtI014IZymIJ.
To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.

Wayne Thomson

unread,
Oct 3, 2012, 7:17:09 PM10/3/12
to robotframe...@googlegroups.com, wayne....@wayju.com
Hi Bulkan,

Thanks for your suggestion, but it still doesn't work for me. Did you try it?

I had two colleagues run the same test. On one machine it passed and on another it failed. They were both running windows XP, I am running windows 7 and the server previously mentioned is running windows 7. 

The two failures occurred on latest versions of robot framework, python, jython (we run tests through Maven), and robot selenium library (though this should have nothing to do with it). I then tried versions which matched the machine which passed the tests, and still to no avail. We tried a share on localhost as well as the original network path on the database server.

Any other suggestions?

Thanks,

Wayne.

Pekka Klärck

unread,
Oct 8, 2012, 2:20:51 AM10/8/12
to Wayne Thomson, robotframework-users
2012/10/7 Wayne Thomson <wayne....@wayju.com>:
>
> Thanks for the response. I ran the python command and it works as expected:
>
>>>> import os
>>>> os.listdir('\\\\localhost\\temp')
> ['aNew Text Document.txt', 'New folder']
>>>>
>
> But running a simple test fails:
>
> Count Files In Directory \\\\localhost\\temp
>
> [INFO] Test
> | FAIL |
> [INFO] Directory '\\localhost\temp' does not exist

Before executing os.listdir, the keyword verifies that the specified
directory exists using os.path.isdir. It seems that on your system
that check fails. Could you try that on the interpreter? You could
actually test the following combinations to see could the difference
be does the path end with a path separator or not, or is it a byte
string or Unicode:

os.path.isdir('\\\\localhost\\temp')
os.path.isdir('\\\\localhost\\temp\\')
os.path.isdir(u'\\\\localhost\\temp')
os.path.isdir(u'\\\\localhost\\temp\\')

Btw, are you running your tests using Python or Jython? If the latter,
you should actually run the tests on Jython interpreter.

Cheers,
.peke

PS: Please keep robotframework-users mailing list on Cc in possible
further replies.
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Wayne Thomson

unread,
Oct 8, 2012, 5:54:23 AM10/8/12
to Pekka Klärck, robotframework-users
Thanks Pekka.

In jython os.listdir returns the folder contents but os.path.isdir returns False.
In python os.listdir returns the folder contents and os.path.isdir returns True.

I guess this points to the direction of the problem. I am currently running python 2.7.2 and jython 2.5.1. I could try different jython versions when at work tomorrow, though I was pretty sure that my colleague and I had the same versions. 

Wayne.

Pekka Klärck

unread,
Oct 15, 2012, 6:55:03 PM10/15/12
to Wayne Thomson, robotframework-users
2012/10/8 Wayne Thomson <wayne....@wayju.com>:
> Thanks Pekka.
>
> In jython os.listdir returns the folder contents but os.path.isdir returns
> False.
> In python os.listdir returns the folder contents and os.path.isdir returns
> True.

Sounds like there is some kind of a weird bug in Jython.

> I guess this points to the direction of the problem. I am currently running
> python 2.7.2 and jython 2.5.1. I could try different jython versions when at
> work tomorrow, though I was pretty sure that my colleague and I had the same
> versions.

Did you find any more information regarding to this? If not, below are
few more questions that might help us to understand what's going on:

- Does your path contain non-ASCII characters?
- When using Jython directly, did you use Unicode or byte string (i.e.
u'path' or 'path')?
- Does os.path.exist(path) work with Jython?
- What does os.stat(path) return?

Because it seems that os.listdir itself works and the problem is in
os.path.isdir, we could consider changing List Directory keyword to
just use the former without verifying that the directory actually
exists before. That would cause slightly worse error messages with
non-existing directories, but that's pretty minor problem compared to
the whole keyword not working. It would be much better to understand
the actual root cause and possibly fix or workaround it, though,
because in the current situation many other OperatingSystem keywords
(e.g. Directory Should Exist) will not work for you anyway.

Cheers,
.peke

Wayne Thomson

unread,
Oct 17, 2012, 8:03:09 PM10/17/12
to Pekka Klärck, robotframework-users
Hi Pekka,

I logged a Jython issue and am waiting to hear back: http://bugs.jython.org/issue1975

I've tried the latest version of jython as well as the version for which it works on my colleagues machine. For now we wrote a quick java keyword to replace the os keyword which doesn't work for some of our systems.

In regards to your questions:

- Does your path contain non-ASCII characters? No, the path is \\localhost\temp
- When using Jython directly, did you use Unicode or byte string (i.e.u'path' or 'path')? This does not make a difference in jython, but both work in python
- Does os.path.exist(path) work with Jython? No (but yes in python) See below
- What does os.stat(path) return? It says that there is no such file or directory. See below

Thanks again,

Wayne.

-------------

D:\iE2>jython
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.stat('\\\\localhost\\temp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: '\\\\localhost\\temp'
>>> os.listdir('\\\\localhost\\temp')
['aNew Text Document.txt', 'New folder']
>>> os.path.exists('\\\\localhost\\temp')
False
>>> →

D:\iE2>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.stat('\\\\localhost\\temp')
nt.stat_result(st_mode=16895, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=4096L, st_atime=1349415447L, st_mtime=1349415447L, st_ctime=1349226494L)
>>> os.listdir('\\\\localhost\\temp')
['aNew Text Document.txt', 'New folder']
>>> os.path.exists('\\\\localhost\\temp')
True

W Jiang

unread,
Oct 8, 2017, 9:21:10 AM10/8/17
to robotframework-users
Hi,

robot framework: Copy file to the network shared fodler: 
It works for me:

OperatingSystem.Copy File    ${gdr402UpgradePackage}    \\\\192.168.1.1\\storage     
OperatingSystem.File Should Exist     \\\\192.168.1.1\\storage\\*.tar.gz



Cheers


To unsubscribe from this group, send email to robotframework-users+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages