I am looking for a function to resolve 'F:/foo/bar' into '/cygdrive/f/
foo/bar'. I get the original dirpath from tkFileDialog.as kdirectory in
a Windows form and none of os.path.* functions seem to resolve it to a
cygwin form. Rather they _append_ it to the current directory,
resulting at best in a monster '/cygdrive/c/whatever/f/foo/bar'.
It's all being developed under cygwin currently (so it is a kind of
mixed environment), but I would like the fix to work correctly in any
environment.
Thanks,
Marcin 5 3593 mg******@gmail. com wrote:
I am looking for a function to resolve 'F:/foo/bar' into '/cygdrive/f/
foo/bar'. I get the original dirpath from tkFileDialog.as kdirectory in
a Windows form and none of os.path.* functions seem to resolve it to a
cygwin form. Rather they _append_ it to the current directory,
resulting at best in a monster '/cygdrive/c/whatever/f/foo/bar'.
It's all being developed under cygwin currently (so it is a kind of
mixed environment), but I would like the fix to work correctly in any
environment.
You can call the cygpath utility:
>>import commands commands.geto utput("cygpath c:/windows")
'/c/windows'
-- Gerhard
On Jan 18, 11:10 am, "mgier...@gmail .com" <mgier...@gmail .comwrote:
I am looking for a function to resolve 'F:/foo/bar' into '/cygdrive/f/
foo/bar'. I get the original dirpath from tkFileDialog.as kdirectory in
a Windows form and none of os.path.* functions seem to resolve it to a
cygwin form. Rather they _append_ it to the current directory,
resulting at best in a monster '/cygdrive/c/whatever/f/foo/bar'.
It's all being developed under cygwin currently (so it is a kind of
mixed environment), but I would like the fix to work correctly in any
environment.
Thanks,
Marcin
Well, you could write it yourself....
(assuming path is a string, here's a first go at it...)
def path_into_cygpa th(path):
drive, destination = path.split(':')
newpath = '/cygdrive/' + drive.lower() + destination
return newpath
On 2008-01-18, apatheticagnost ic <ap************ ***@gmail.comwr ote:
On Jan 18, 11:10 am, "mgier...@gmail .com" <mgier...@gmail .comwrote:
>I am looking for a function to resolve 'F:/foo/bar' into '/cygdrive/f/ foo/bar'. I get the original dirpath from tkFileDialog.as kdirectory in a Windows form and none of os.path.* functions seem to resolve it to a cygwin form. Rather they _append_ it to the current directory, resulting at best in a monster '/cygdrive/c/whatever/f/foo/bar'. It's all being developed under cygwin currently (so it is a kind of mixed environment), but I would like the fix to work correctly in any environment.
Thanks, Marcin
Well, you could write it yourself....
(assuming path is a string, here's a first go at it...)
def path_into_cygpa th(path):
drive, destination = path.split(':')
newpath = '/cygdrive/' + drive.lower() + destination
return newpath
Don't forget to convert backslashes into forward slashes.
--
Grant Edwards grante Yow! TONY RANDALL! Is YOUR
at life a PATIO of FUN??
visi.com
On Jan 18, 11:48 am, Grant Edwards <gra...@visi.co mwrote:
On 2008-01-18, apatheticagnost ic <apatheticagnos ...@gmail.comwr ote:
On Jan 18, 11:10 am, "mgier...@gmail .com" <mgier...@gmail .comwrote:
I am looking for a function to resolve 'F:/foo/bar' into '/cygdrive/f/
foo/bar'. I get the original dirpath from tkFileDialog.as kdirectory in
a Windows form and none of os.path.* functions seem to resolve it to a
cygwin form. Rather they _append_ it to the current directory,
resulting at best in a monster '/cygdrive/c/whatever/f/foo/bar'.
It's all being developed under cygwin currently (so it is a kind of
mixed environment), but I would like the fix to work correctly in any
environment.
Thanks,
Marcin
Well, you could write it yourself....
(assuming path is a string, here's a first go at it...)
def path_into_cygpa th(path):
drive, destination = path.split(':')
newpath = '/cygdrive/' + drive.lower() + destination
return newpath
Don't forget to convert backslashes into forward slashes.
--
Grant Edwards grante Yow! TONY RANDALL! Is YOUR
at life a PATIO of FUN??
visi.com
Whoops.
Here we go then (are forward slashes valid in a filename in windows?)
def path_into_cygpa th(path):
drive, destination = path.replace('\ \','/').split(':')
return '/cygdrive/' + drive.lower() + destination
Well yes, I was hoping for a library function, but none provides it.
Thanks for the code. Works nicely.
On Jan 18, 12:12 pm, apatheticagnost ic <apatheticagnos ...@gmail.com>
wrote:
Here we go then (are forward slashes valid in a filename in windows?)
def path_into_cygpa th(path):
drive, destination = path.replace('\ \','/').split(':')
return '/cygdrive/' + drive.lower() + destination
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vamsi Mudrageda |
last post by:
I am kind of new to Python, and after trying and using wxPython, I found
it kind of lacking in easy-to-read documentation, speed at loading, and
GUI response-time.
So I am looking for an another GUI toolkit that is cross-platform for
Python, and am leaning toward PyQt (PyGTK is kind of dull looking in
comparison). Unfortunately, although TrollTech says Qt is
cross-platform, its license strategy has me a bit confused. So here is
to...
|
by: Bill Grigg |
last post by:
Gentlemen,
I am hoping to be able to use GForge on my windows PC. To that end I
have installed:
1. cygwin
2. reinstalled cygwin and selected cygipc, postgreSQL and a few other
things
3. PHP
4 Apache
5. downloaded and installed the GForge3 directory tree
|
by: Claudio Grondi |
last post by:
I need to unpack on a Windows 2000 machine
some Wikipedia media .tar archives which are
compressed with TAR 1.14 (support for long file
names and maybe some other features) .
It seems, that Pythons tarfile module is able to list far
more files inside the archives than WinRAR or 7zip or
TotalCommander, but will it unpack all available files
(largest archive size 17 GByte)?
If tarfile is build on TAR 1.14 or TAR 1.15 it will be
|
by: Abby |
last post by:
I'm now using Cygwin as my compiler for C code. I use Dev-c++ as my
editor.
The reason why I chose Cygwin compiler instead of the compiler that
came with Dev-C++ is that I believe it uses the same environment as in
Linux, so that I don't have to write different sourcecode for both OS.
Eventhough, I don't understand about Linux much, and I'm still a
beginner in programming, I still have to make my program compatible
with both OS (Windows...
|
by: Hugh Cowan |
last post by:
Hello,
I am looking at getting a simple compiler for Windows that I can use
to play around with different Open Source software.
I am not a full-time programmer (anymore), nor do I plan to write
software either. I just want to play around and look at some of the
Open Source software that is out there for Windows.
Most of the applications are written in C, or C++ and therefore I
| |
by: Julien Fiore |
last post by:
Do you wand to install Pyrex on Windows ?
Here is a step-by-step guide explaining:
A) how to install Pyrex on Windows XP.
B) how to compile a Pyrex module.
Julien Fiore,
U. of Geneva
|
by: reachsamdurai |
last post by:
Hello,
Can you please let me know the procedure to reach db2 command prompt
from a cygwin window (hence without using Start-> Run -> db2cmd
method). I'm planning to write shell scripts which accesses DB2
database on windows platform hence I installed cygwin but I'm unable to
connect to database as it fails with the error message.
$ db2
DB21061E Command line environment not initialized.
|
by: anand.ba |
last post by:
Hi all
I need to find equivalent windows libraries for the following unix
ones.
#include <sys/prctl.h>
#include <sys/ioctl.h>
#include <unistd.h>
|
by: kai rosenthal |
last post by:
Hello,
with ls -l on windows I get
-rw-r--r-- 1 500 everyone 320 Nov 09 09:35 myfile
How can I get on windows with a standard python 2.2 (without windows
extensions) the information "500" and "everyone" (owner and group)?
Also I cannot use popen('ls -l').
With
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |