Archive

Posts Tagged ‘python’

FTP for Developers

January 29th, 2009 2 comments

FTP for Developers

This examples upload a simple text file for a better implementations read the API or documentation for each language or command

Curl:

curl -T filename -u username:password ftp://hostname/filename

Perl:

use Net::FTP;
$hostname = "localhost";
$username = "user";
$password = "pass";
$filename = "file.txt";
$ftp = Net::FTP->new($hostname);
$ftp->login($username,$password);
$ftp->put($filename);
$ftp->quit;

To handle errors use “or die $@” (“$ftp>message” only if login success)

PHP:

<?php
$hostname = "localhost";
$username = "user";
$password = "pass";
$filename = "file.txt";
$conn = ftp_connect($hostname); 
ftp_login($conn, $username, $password);
ftp_put($conn,$filename,$filename,FTP_ASCII);
ftp_close($conn);
?>

To handle erros you can use “if(!function)”

Python:

import ftplib
hostname = "localhost"
username = "user"
password = "pass"
filename = "file.txt"
ftp = ftplib.FTP(hostname)
ftp.login(username, password) 
ftp.storlines("STOR " + filename, open(filename))
ftp.quit()

To handle errors use “try” and “except” and “else”

Ruby:

require 'net/ftp'
host = 'localhost'
user = 'user'
pass = 'pass'
file = 'file.txt'
ftp = Net::FTP.new(hostname)
ftp.login(username,password)
ftp.puttextfile(filename)
ftp.close

To handle errors use “begin”, “rescue”, “else”, “ensure” and “end”.

Win32 batch:

ftp -s:settings.txt hostname

settings.txt:

username
password
put filename
bye

To handle errors use “if not %errorlevel%==0 goto :error”

Python and NetBeans

January 23rd, 2009 1 comment

Python and NetBeans

Menu => Tools => Plugins


New Python Project:




Jython ( http://www.jython.org )
Python ( http://www.python.org )

Categories: develop, unix/linux, windows Tags: ,

Python 3.0 Final Released

December 4th, 2008 No comments

Python 3.0 Final Released

Python 3.0 (a.k.a. “Python 3000″ or “Py3k”) is a new version of the language that is incompatible with the 2.x line of releases. The language is mostly the same, but many details, especially how built-in objects like dictionaries and strings work, have changed considerably, and a lot of deprecated features have finally been removed. Also, the standard library has been reorganized in a few prominent places.

What’s New and download.

Categories: develop Tags:

TODO LIST 2009

December 1st, 2008 1 comment

TODO LIST 2009

Read/Learn/Practice:

Python 2.6 (What’s New)

Perl 5 (Modules, Packages)

PHP (Changes, and news)

COBOL

.NET (C#, LINQ, (ok VB but not much))

Java (Im interested on Mobil Applications)

Haskell

Ruby (Im interested on Rails)

Parrot and Pugs

Gnu/Linux (Services and Bash)

BSD and OpenSolaris

Personal Projects 2009:

BSE (Blog’s Search Engine) (http://BSE.AyalaSoft.com)

Invoices PHP (Now is part of a Intranet) (http://valuacion.com.mx)

Forming one’s own business

And others ….

Lambda Functions on PHP 5.3.0:

 $lambda = function () { echo "Hello World!\n"; };

Parrot “Hello World” example:

.sub main
      print "Hello World!\n";
.end

COBOL “Hello World” example:

* Hello World Program
* GPL Copyleft Jonathan Riddell 2001
	IDENTIFICATION DIVISION.
	PROGRAM-ID.    hello.
	ENVIRONMENT DIVISION.
	DATA DIVISION.
 
	PROCEDURE DIVISION.
		DISPLAY "Hello ," WITH NO ADVANCING
		DISPLAY "World!"
		STOP RUN.

Haskell “Hello World” example:

putStrLn "Hello World!"

Google App Engine

November 5th, 2008 No comments

Google App Engine

Downloads (http://code.google.com/appengine/downloads.html)

Google App Engine use Django, webob, yaml.

You need Python (http://www.python.org) (Python 2.5)

The configuration file app.yaml

There are two main Python scripts:

Video from the The Google Code Channel:

See the applications gallery

Google App Engine

Switch to our mobile site