path

Django ImageField / FileField custom upload_to function, and security

Hi. I have part of a model defined like this: logo_image = models.ImageField(upload_to=lambda i, fn: "logo_%s"%(fn), height_field="logo_image_height", width_field="logo_image_width") and had a question about the upload_to function. According to django's documentation for FileField.upload_to, the second paramater, filename is "The fil...

Python module search path problem

Hi, I am trying to work on a dev environment but am find problems in that python seems to be using modules from the site-packages directory. I want it to be using the modules from my dev directory. sys.path returns a bunch of dirs, like this ['', '/usr/lib/python26.zip', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib...

eclipse and path

Hello I have written a such function under Eclipse: public static ArrayList<String> getMails(){ ArrayList<String> mails = new ArrayList<String>(); try{ FileInputStream fstream = new FileInputStream("mails.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedRea...

Why Path.Combine doesn't add the Path.DirectorySeparatorChar after the drive designator?

var actual = Path.Combine("c:", "filename"); var expected = @"c:\filename"; Assert.AreEqual(expected, actual); Result {Assert.AreEqual failed. Expected:<c:\filename>. Actual:<c:filename>. Why? ...

Getting a file path from a file handle in Windows

In Windows, is there a straightforward way to get the full path of a file, given only the file's handle? I can't use GetFinalPathNameByHandle() because that's Vista+ only and our product has to work on XP. However, something that simple, or close to it, would be best. ...

How to properly make path handling robust in a bash program?

The script have some hard-coded relative paths. I would like them to be relative to script position. The script needs to change current directory as some other program (cmake) needs it. The script takes some (possibly relative to caller) paths as an argument and it passes them to that program, they should be derelativized. Questions a...

Is there a version of os.getcwd() that doesn't dereference symlinks?

I have a Python script that I run from a symlinked directory, and I call os.getcwd() in it, expecting to get the symlinked path I ran it from. Instead it gives me the "real" path, and in this case that's not helpful. I need it to actually give me the symlinked version. Does Python have a command for that? ...

How to specify rubygems path in environment-less Ruby script?

I've written a data collection script for Cacti in Ruby and it runs fine from the command line but Cacti runs the script via "env -i" which strips the environment so Ruby can't find the rubygems library ("in `require': no such file to load -- rubygems (LoadError)"). How might I work around this? ...

Convert file path to a file URI?

Does the .NET Framework have any methods for converting a path (e.g. "C:\whatever.txt") into a file URI (e.g. "file:///C:/whatever.txt")? The Uri class has the reverse (from a file URI to absolute path), but nothing as far as I can find for converting to a file URI. Also, this is NOT a ASP.NET application. Thanks! ...

Problem with drawing paths with Core Graphics - iPhone

Hi, I am trying to draw a map annotation in my app - very much like MapKit's MKAnnotationView, but without the mapkit. I have a problem with the ordering of the path for the view outline that I cant figure out. Image of results: http://img504.imageshack.us/img504/5458/screenshot20091010at703.png Code: CGFloat minx = CGRectGetMinX(cu...

mplayer -ao pcm:file=C:\x.wav

Not sure where this should be posted... Anyway, if i run the following command in a windows XP console it gives me a weird error and i have no ideea why. mplayer "1.mp3" -vc "null" -vo "null" -ao "pcm:file=C:\1.wav" Could not parse arguments at the position indicated below: file=C:\1.wav ^ Failed to initialize audio driver 'pcm...

Copying live sites to local

Recently I've been getting more and more into web development and as such have a few questions. I have a few websites that are on a production LAMP server and I've been trying to copy them to my local computer running xampp 1.7.1 on XP Pro. The problem I've been having is mostly path issues. I mainly develop for wordpress, joomla, magent...

How can I find out where a Perl module is installed?

How do get the path of a installed Perl module by name, e.g. Time::HiRes? I want this just because I have to run my perl script on different nodes of a SGE Grid Engine system. Sometimes, even run as other username. I can use CPAN.pm to install packages for myself, but it is not so easy to install for other users without chmod 666 on fo...

Using Named Pipes as Files

Simple question here (though perhaps not such a simple answer): Is it possible to specify a path for an (existing) named pipe that can be used by programs as if they were opening on a normal file? According to this MSDN page, name pipes on the local computer can be referrenced using the following path syntax: \\.\pipe\PipeName, yet I'm...

Can't find the path!

Hi, I'm currently developing an collage application for iPhone and I've now at the point of saving the image and I therefore need the correct path so that the images shows in your image library. Does anyone know the address to the path? BR, drisse ...

Checking if removing an edge in a graph will result in the graph splitting

I have a graph structure where I am removing edges one by one until some conditions are met. My brain has totally stopped and i can't find an efficient way to detect if removing an edge will result in my graph splitting in two or more graphs. The bruteforce solution would be to do an bfs until one can reach all the nodes from a random n...

Storing a file in the user's directory in cross-platform Java

I have a Java application that runs on Mac and Windows, directly off a CD/DVD with no installation. Now, I need to store a file containing per-user data (think favourites etc.) somewhere on the local file system, so that it can be written to. So, where do you think is a good location for this file? I am thinking something like: <USER_...

Access to the path '\\Image0\Abc' is denied.

var directory = new DirectoryInfo( "\image0\Abc" ); if (!directory.Exists) { directory.Create(); } when I user above asp.net code which unc path, I found the following problem. How can I solve? Access to the path '\Image0\Abc' is denied. Regards, atk ...

How to map file path from different folder location easily?

how to map the path to the file easily? public_html/api/function.php <?php function writetologfile($content) { $filename = 'logfile/testing_randomstring.txt'; if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } fclose($handle); } ?> the actual path of the text file i...

WPF Change a rectangles points at runtime

Hi All, I have a WPF app in which I need to programatically manipulate at runtime. What I thought of doing is having a Path with 4 line segments like so: Canvas.Left="324" Canvas.Top="247"> <Path.Data> <PathGeometry> <PathFigure IsClosed="True"> <LineSegmen...