Síguenos en Facebook


Síguenos en Twitter

Compartir este tema:
El 21 mayo, 2011 · 0 Comentarios
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Nombre del Programa: SharkTube

Versión del Programa: 1.1 ( Renaissance )

Autor(es): Sebastián Castaño (.:WindHack:.)

Sistema Operativos: Multiplataforma.

- Lenguaje en que fue programado: Python 2.6.x

Licencia bajo la que fue liberado: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0Ver Registro en SafeCreative.org

Fecha de lanzamiento: 12 de abril de 2011

Idioma(s): Español/Inglés

Funcionalidad/Tópico del Programa: Script para descargar directamente vídeos de YouTube.

Captura de pantalla del programa ejecutándose:

Para ver la información completa y los enlaces de descarga, clic AQUÍ.

 

Compartir este tema:
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Este es un pequeño tip para quitar la flecha que se muestra en un acceso directo. Es muy sencillo y el resultado es agradable.

Para ver el tutorial clic AQUÍ.

Compartir este tema:
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

En este tutorial se enseña a instalar los componentes necesarios para monitorear la temperatura de nuestro equipo.

Para ver el tutorial clic AQUÍ.

Compartir este tema:
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Un sencillo tutorial en el cual se explica de manera rápida y efectiva la forma de crear una USB booteable para instalar el sistema operativo Windows.

Para ver el tutorial clic AQUÍ.

 

Compartir este tema:
El 24 marzo, 2011 · 0 Comentarios
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Nombre del Programa: WS Downloader

Versión del Programa: 0.1 (Beta)

Autor(es): Sebastián Castaño (.:WindHack:.) y Carlos Sánchez (swik)

Sistema Operativos: Multiplataforma.

- Lenguaje en que fue programado: Python 2.6.x

Licencia bajo la que fue liberado: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0Ver Registro en SafeCreative.org

Fecha de lanzamiento: 17 de noviembre de 2010

Idioma(s): Español

Funcionalidad/Tópico del Programa: Script para descargar directamente vídeos de YouTube.

Captura de pantalla del programa ejecutándose: NA

Código:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# WS Downloader.py - v0.1 (Beta)
# Autor(es): .:WindHack:. & swik
# :www.daw-labs.com | :www.cibernodo.net
# Registrado en SafeCreative
# Licencia: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0
# 17/11/2010
 
import sys, urllib, os
 
#
# @Charset
#
Char = ['%3A','%2F','%26','%2C','%3D','%252C','%253A','%7C','%3F']
By =   [':','/','&',',','=',',',':','','?']
 
#
# URLDecode(sURL)
# Descifra la URL teniendo en cuenta el Charset.
#
def URLDecode(sURL):
    for i in range(len(Char)):
    	sURL = sURL.replace(Char[i],By[i])
    return sURL
 
#
# GetSourceCode(sURL)
# Obtiene el código de fuente del vídeo (sitio).
#
def GetSourceCode(sURL):
    try:
    	URL = urllib.urlopen(sURL)
    	sSource = URL.read()
    	URL.close()
    	return sSource
    except:
        print 'Error de conexión.'
        exit()
 
#
# GetIndexVideo(sSource,Tags)
# Obtiene la posición de un "Tag" o etiqueta.
#
def GetIndexVideo(sSource,Tags):
    return sSource.find(Tags)
 
#
# GetVideoTitle(sSource)
# Obtiene el título del vídeo.
#
def GetVideoTitle(sSource):
    sSource = sSource[2000:5500]
    Begin = GetIndexVideo(sSource,'
Compartir este tema:
El 24 marzo, 2011 · 3 Comentarios
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Sudokux es una aplicación en Java, capaz de resolver en menos de un segundo cualquier sudoku que le propongas.

Nombre del Programa: Sudokux.

Versión del Programa: 1.0.

Autor(es): Pablo Martínez Insua (pablomi).

Sistema Operativo: Multiplataforma.

Lenguaje en que fue programado: Java 1.6.x.

Licencia bajo la que fue liberado: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0. Ver registro en Safe Creative.

Fecha de lanzamiento: 06 – 09 – 2010.

Idioma(s): Español.

Captura:

Código:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
 
// Sudokux 1.0 - Pablo Martínez Insua
//
// Programa registrado.
// Licencia: -http://creativecommons.org/licenses/by-nc-sa/3.0/deed.es_PE
 
public class Sudokux {
 
	private static int[][] casilla;
 
	JFrame ventana = new JFrame("Sudokux 1.0");
	JMenuBar menus = new JMenuBar();
	JMenu menuArchivo = new JMenu("Archivo");
	JMenu menuHelp = new JMenu("Ayuda");
	JMenuItem archivoSalir = new JMenuItem("Salir");
	JMenuItem helpAcercaDe = new JMenuItem("Acerca de");
 
	Font fontRespuesta = new Font("Verdana", Font.BOLD, 20);
	JButton resolver = new JButton("Resolver");
	JButton borrar = new JButton("Borrar");
 
	JTextField numeros[][] = new JTextField[10][10];
 
	String solucion;
 
	public static void main(String[] args){
 
		casilla = new int[10][10];
 
		for(int col=0; col<9; col++)
			for(int fil=0; fil<9 ; fil++)
				casilla[fil][col] = 0;
 
		Sudokux mostrarVentana = new Sudokux();
	}
 
	public Sudokux(){
		configurar();
		acciones();
	}
 
	void configurar(){
		menuArchivo.add(archivoSalir);
		menuHelp.add(helpAcercaDe);
		menus.add(menuArchivo);
		menus.add(menuHelp);
 
		for(int i=1; i<10; i++){
			for(int j=1; j<10; j++){
				numeros[i][j] = new JTextField(1);
				ventana.add(numeros[i][j]);
				numeros[i][j].setFont(fontRespuesta);
			}
		}	
 
		ventana.add(menus);
		ventana.setJMenuBar(menus);
		ventana.add(resolver);
		ventana.add(borrar);
		ventana.setVisible(true);
		ventana.setSize(300, 420);
		ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		ventana.setLayout(new FlowLayout(FlowLayout.CENTER));
	}
 
	void acciones(){
 
		archivoSalir.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				System.exit(0);
			}
		});
 
		helpAcercaDe.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				JOptionPane.showMessageDialog(null, "Programa: Sudokux\nAutor: Pablo Martínez Insua\nVersión: 1.0", "Acerca de", JOptionPane.INFORMATION_MESSAGE);
			}
		});
 
		resolver.addMouseListener(new MouseAdapter(){
			public void mousePressed(MouseEvent e){
				recoger_datos();
				resuelve(1,1);
				for (int col=1; col<10; col++){
            				for (int fil=1; fil<10 ; fil++){
						numeros[fil][col].setText(""+casilla[fil][col]);
					}
				}
 
			}
		});
		borrar.addMouseListener(new MouseAdapter(){
			public void mousePressed(MouseEvent e){
				for (int col=1; col<10; col++){
            				for (int fil=1; fil<10 ; fil++){
						numeros[fil][col].setText("");
						casilla[fil][col] = 0;
					}
				}
 
			}
		});
	}
 
 
	void recoger_datos(){
		int tiene = 1;
		for (int col=1; col<10; col++){
            		for (int fil=1; fil<10 ; fil++){
				if(!numeros[fil][col].getText().equals(""))
					casilla[fil][col] = Integer.parseInt(numeros[fil][col].getText());
					tiene = 0;
			}
		}
		if(tiene==1){
			JOptionPane.showMessageDialog(null, "Introduce el sudoku a resolver.", "Error", JOptionPane.WARNING_MESSAGE);
		}
	}
 
	private static boolean resuelve(int fil, int col){
 
        	boolean resuelto = false, casillaSegura = false;
        	int num = 1;
 
		if (casilla[fil][col]!=0)
        	{
            		casillaSegura = true;
            		num=9;
		}
 
		while(!resuelto && num<10)
		{
			if(!casillaSegura)
				casilla[fil][col] = num;
			if(es_valida(fil,col))
			{
				if(fil==9 && col==9)
					resuelto = true;
				else if (fil<9)
 					resuelto = resuelve(fil+1, col);
				else if(fil==9)
					resuelto = resuelve(1, col+1);
			}
			num++;
		}
 
		if (!resuelto && !casillaSegura)
			casilla[fil][col] = 0;
 
		return resuelto;
	}
 
	private static boolean es_valida(int fil, int col){
 
		for(int i=1; i<10; i++)
			if(fil!=i && casilla[fil][col] == casilla[i][col])
				return false;
 
		for (int i=1; i<10; i++)
			if (col!=i && casilla[fil][col] == casilla[fil][i] )
				return false;
 
		int cuadroColumna = (int)(Math.floor((col-1)/3)*3)+1,
		    cuadroFila = (int)(Math.floor((fil-1)/3)*3)+1;
 
		for(int i=cuadroColumna; i<cuadroColumna +3; i++)
			for (int j=cuadroFila; j<cuadroFila+3; j++)
				if(col!=i && fil!=j && casilla[fil][col] == casilla[j][i])
					return false;
 
		return true;
	}
}
Compartir este tema:
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Goxar es un editor de texto plano con las funciones tipicas de uno de este. Carece de menu de edición. En su versión 1.0 cuenta con funciones de abrir, guardar.

Nombre del Programa: Goxar Editor de texto plano.

Versión del Programa: 1.0.

Autor(es): Carlos Sánchez (swik).

Sistema Operativo: Windows XP SP3.

Lenguaje en que fue programado: Python 2.6.x.

Licencia bajo la que fue liberado: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0.

Fecha de lanzamiento: 28/8/10.

Idioma(s): Español.

Capturas:

Código:

#-*- coding: iso-8859-1 -*-
 
#Goxar editor
#Agradecimientos a Sifaw
#Copyright © 2010
#Autor: swik
#Bajo licencia
 
import wx, os
 
ID_OPEN = 5000
ID_NEW = 5002
ID_SAVE = 5003
ID_SaveAS = 5004
ID_EXIT = 5006
ID_ABOUT = 5014
 
class Editor(wx.MiniFrame):
    def __init__ (self):
        wx.MiniFrame.__init__(self, None, -1, 'Goxar Editor', wx.DefaultPosition, (900, 700), (wx.DEFAULT_FRAME_STYLE)^(wx.RESIZE_BORDER|wx.MAXIMIZE_BOX))
 
        panel = wx.Panel(self, wx.NewId(), wx.DefaultPosition, (900, 700))
        self.edit = wx.TextCtrl(panel, size=(900, 700), style=wx.TE_MULTILINE)
        self.CreateStatusBar()
        self.SetStatusText("Barra de estado - Goxar Editor de texto plano")
 
        #-----------------------------------------------------------------------
        menubar = wx.MenuBar()
        #menu de archivo
        archi = wx.Menu()
        archi.Append(ID_NEW, 'Nuevo', 'Limpia el contenido para comenzar un archivo nuevo')
        archi.Append(-2, '', '')
        archi.Append(ID_OPEN, 'Abrir', 'Abre un archivo')
        archi.Append(ID_SAVE, 'Guardar', 'Guarda el archivo previamente guardado')
        archi.Append(ID_SaveAS, 'Guardar como', 'Guarda el archivo')
        archi.Append(-2, '', '')
        archi.Append(ID_EXIT, 'Salir', 'Sale del programa')
 
        #menu de ayuda
        ayu = wx.Menu()
        ayu.Append(ID_ABOUT, 'Acerca de...', 'Mas informacion acerca del programa')
 
        #eventos
        wx.EVT_MENU(self, wx.ID_EXIT,  self.onClose)
        wx.EVT_MENU(self, wx.ID_ABOUT, self.onAbout)
        wx.EVT_MENU(self, wx.ID_OPEN, self.onOpen)
        wx.EVT_MENU(self, wx.ID_SAVEAS, self.onSaveAS)
        wx.EVT_MENU(self, wx.ID_SAVE, self.onSave)
        wx.EVT_MENU(self, wx.ID_NEW, self.onNew)
 
        #barra de menu
        menubar.Append(archi, '&amp;Archivo')
 
        menubar.Append(ayu, '&amp;Ayuda')
        self.SetMenuBar(menubar)
        #----------------------------------------------------------------------
 
    #cerrar
    def onClose(self, *event):
        self.Close(True)
    #acerca de
    def onAbout(self,e):
        dlg1 = wx.MessageDialog( self, "Goxar Editor de texto plano v1.0", "", wx.OK)
        dlg2 = wx.MessageDialog( self, "Copyright © 2010 ", "", wx.OK)
        dlg1.ShowModal()
        dlg2.ShowModal()
        dlg1.Destroy()
        dlg2.Destroy()
 
    #abrir
    def onOpen(self,event):
        self.dirname = ''
        dlg = wx.FileDialog(self, "Goxar: Abrir", self.dirname,"", "*.*", wx.OPEN)
        if dlg.ShowModal()==wx.ID_OK:
            self.filename=dlg.GetFilename()
            self.dirname=dlg.GetDirectory()
            a = open(self.filename, 'r')
            self.edit.SetValue(a.read())
            self.edit.write(self.filename)
 
    def onSaveAS(self,event):
        self.dirname = ''
        dlg1 = wx.FileDialog(self, "Goxar: Guardar como", self.dirname, "", "*.*", wx.SAVE | wx.OVERWRITE_PROMPT)
        if dlg1.ShowModal() == wx.ID_OK:
            conten = self.edit.GetValue()
            self.filename=dlg1.GetFilename()
            self.dirname=dlg1.GetDirectory()
            filehandle=open(os.path.join(self.dirname, self.filename),'w')
            filehandle.write(conten)
            filehandle.close()
        dlg1.Destroy()
 
    def onSave(self,event):
        grab = self.edit.GetValue()
        a = open(self.filename, 'w')
        a.write(grab)
        a.close()
 
    def onNew(self,event):
        self.edit.Clear()
 
class App(wx.App):
    def OnInit(self):
        frame = Editor()
        frame.Show()
        self.SetTopWindow(frame)
        return True
 
if __name__ == '__main__':
    app = App()
    app.MainLoop()
Compartir este tema:
El 24 marzo, 2011 · 0 Comentarios
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Servlet encargado de recibir una petición POST desde un formulario html y verificar la información recibida en una base de datos mysql, usando para ello el conector jdbc. Si la información es correcta, crea una cookie en el navegador y carga la pagina que deseemos, de ser falsa, carga otra pagina. (Cambios mínimos en el código son requeridos).

Nombre del Programa: Servlet DataBase.

Versión del Programa: NA.

Autor(es): Oswaldo Gutierrez (-Gosw-) y Widnelzy Salas (yuyiwid).

Sistema Operativos: Windows XP SP3.

Lenguaje en que fue programado: Java 1.6.x.

Licencia bajo la que fue liberado: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0 , Ver Registro en SafeCreative.org.

Fecha de lanzamiento: 14 de Octubre del 2009.

Idioma(s): NA.

Captura de pantalla del programa ejecutándose: NA.

Código:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
 
public class ServletDataBase extends HttpServlet
{
    static String login = "User";
    static String password = "Password";
    static String url = "jdbc:mysql://localhost:3306/BaseDeDatos";
 
    @Override
    public void init(ServletConfig conf) throws ServletException
    {
        super.init(conf);
    }
 
    @Override
    protected void doPost(HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
    {
        String usuario = peticion.getParameter("usuario"); //vendra del formulario
        String pass = peticion.getParameter("pass"); //vendra del formulario
        Connection conexion = null; //Objeto para la conexión a la BD
        Statement sentencia = null; //Objeto para la ejecutar una sentencia
        ResultSet resultados = null;//Objeto para guardar los resultados
        Cookie[] cks = peticion.getCookies();
        respuesta.setContentType ("text/html");
	PrintWriter salida = respuesta.getWriter();
 
        try
        {
            //Leemos el driver JDBC
            Class.forName("com.mysql.jdbc.Driver");
 
            //Nos conectamos a la BD
            conexion = DriverManager.getConnection(url,login,password);
 
            //Creamos una sentencia a partir de la conexión
            sentencia=conexion.createStatement();
 
 
            //Tomamos todos los datos de la asignaturas
            resultados=sentencia.executeQuery("SELECT user,password FROM usuarios");
 
 
           //Preguntamos si existe Usuario
            while(resultados.next())
            {
                if(usuario.equals(resultados.getString("user")) && pass.equals(resultados.getString("password")))
                {
                    if (cks == null)
                    {
                        Cookie LogCedea = new Cookie("Usuario",usuario);
                        LogCedea.setMaxAge(900);
                        LogCedea.setPath("/CarpetaDeAplicacion");
                        respuesta.addCookie(LogCedea);
 
                        salida.println("<?xml version = \"1.0\"?>");
                        salida.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
                        salida.println("<html xmlns = \"http://www.w3.org/1999/xhtml\">");
                        salida.println("<head>");
                        salida.println("<title>Login Correcto</title>");
                        salida.println("<meta http-equiv=\"Refresh\" content=\"3;url=http://La_Direccion_que_desees_que_llame\">");
                        salida.println("</head>");
                        salida.println("<body>");
                        salida.println("<br />
<h1>Bienvenido</h1>
<p>");
                        salida.println("<br />
<h3>Espere la Redireccion</h3>
<p>");
                        salida.println("</body>");
                        salida.println("</html>");
                        salida.close();
                    }
                    else
                    {
                        salida.println("<?xml version = \"1.0\"?>");
                        salida.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
                        salida.println("<html xmlns = \"http://www.w3.org/1999/xhtml\">");
                        salida.println("<head>");
                        salida.println("<title>Login Correcto</title>");
                        salida.println("<meta http-equiv=\"Refresh\" content=\"3;url=http://La_Direccion_que_desees_que_llame\">");
                        salida.println("</head>");
                        salida.println("<body>");
                        salida.println("<br />
<h1>Bienvenido</h1>
<p>");
                        salida.println("<br />
<h3>Espere la Redireccion</h3>
<p>");
                        salida.println("</body>");
                        salida.println("</html>");
                        salida.close();
                    }
                }
            }
 
            salida.println("<?xml version = \"1.0\"?>");
            salida.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
            salida.println("<html xmlns = \"http://www.w3.org/1999/xhtml\">");
            salida.println("<head>");
            salida.println("<title>Login Incorrecto</title>");
            salida.println("<meta http-equiv=\"Refresh\" content=\"3;url=http://La_Direccion_que_desees_que_llame\">");
            salida.println("</head>");
            salida.println("<body>");
            salida.println("<br />
<h1>Usuario o Clave Incorrectos, por favor intente de nuevo</h1>
<p>");
            salida.println("<br />
<h3>Espere la Redireccion</h3>
<p>");
            salida.println("</body>");
            salida.println("</html>");
            salida.close();
        }
        catch (ClassNotFoundException e1)
        {
            salida.println("No se encontró el driver de la BD: "+e1.getMessage());
        }
        catch (SQLException e2)
        {
            salida.println("Fallo en SQL: "+e2.getMessage());
        }
 
       finally
       {
            try
            {
                if (conexion!=null)
                    conexion.close();
            }
            catch (SQLException e3)
            {
                salida.println("Fallo al desconectar SQL: "+e3.getMessage());
            }
        }
    }
 
    @Override
    protected void doGet(HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
    {
        doPost(peticion, respuesta);
    }
}
Compartir este tema:
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Aplicación para la descarga de archivos de música desde internet.

Nombre: Metáfora Music Downloader.

Version: 2.0.

Autor: Fernando Gómez (Sifaw).

Sistemas Operativos: Multiplataforma. Programado bajo MacOSX por lo que en los demás sistemas puede tener fallos estéticos.

Lenguaje: Python 2.5.4.

Licencia: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0.

Fecha de lanzamiento: 22/08/10.

Idioma: Español.

Capturas:

Video:

Código:

#importamos los modulos
 
 
#! /usr/bin/python
import wx
import thread
import urllib as u
 
class Busqueda(wx.Panel):
    def __init__(self, panel):
        #Colocamos los botones
        wx.Panel.__init__(self, panel)
        self.search = wx.SearchCtrl(self, size=(300, -1), style=wx.TE_PROCESS_ENTER)
        self.search.ShowCancelButton(True)
        npag = wx.StaticText(self, label='N de paginas')
        self.pag = wx.SearchCtrl(self, size=(50, -1), style=wx.TE_PROCESS_ENTER)
        self.pag.SetValue('0')
        self.pag.ShowSearchButton(False)
        canc = wx.StaticBox(self, label='Lista de canciones', size=(290, 225))
        self.lista = wx.ListBox(self, size=(280, 215), style=wx.LB_SINGLE)
        topsizer = wx.BoxSizer(wx.HORIZONTAL)
        topsizer.Add(self.search, 0, wx.ALL|wx.EXPAND, 3)
        middlesizer = wx.BoxSizer(wx.HORIZONTAL)
        middlesizer.Add(npag, 0, wx.ALL, 3)
        middlesizer.Add(self.pag, 0, wx.ALL, 3)
        footsizer = wx.StaticBoxSizer(canc, wx.VERTICAL)
        footsizer.Add(self.lista, 0, wx.ALL, 0)
        totalsizer = wx.BoxSizer(wx.VERTICAL)
        totalsizer.Add(topsizer, 0, wx.ALL|wx.EXPAND, 3)
        totalsizer.Add(middlesizer, 0, wx.ALL|wx.ALIGN_RIGHT, 3)
        totalsizer.Add(footsizer, 0, wx.ALL, 3)
        self.SetSizer(totalsizer)
        totalsizer.Fit(self)
        self.lista.Bind(wx.EVT_LEFT_DCLICK, self.eleccion)
        self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.cancelbusca, self.search)
        self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.cargar, self.search)
        self.Bind(wx.EVT_TEXT_ENTER, self.cargar, self.search)
 
    def cancelbusca(self, event):
        self.search.SetValue('')
 
    def eleccion(self, event):
        pg2.listdesc.Append(self.lista.GetString(self.lista.GetSelection()), self.lista.GetClientData(self.lista.GetSelection()))
 
    def cargar(self, event):
        #Nos conectamos a goear y realizamos la busqueda selccionada mostrandolo en el listbox
        pag = int(self.pag.GetValue())
        busqueda = ''
        for i in self.search.GetValue():
            if i == ' ':
                busqueda += '+'
            else:
                busqueda += i
        self.lista.Clear()
        n = 0
        while n <= pag:
            web = u.urlopen('http://www.goear.com/search.php?q=%s&p=%i' % (busqueda, n))
            web = web.read()
            i = web.find('Escuchar')
            fin = False
            url = False
            canciones = []
            lugar = []
            but = ''
            can = 0
            while fin != True:
                while web[i:i+8] != 'Escuchar':
                    i += 1
                while url == False:
                    i += 1
                    if (web[i] == '"') and (web[i+1] == 'l'):
                        url = True
                i += 1
                while web[i] != '"':
                    but += web[i]
                    i += 1
                lugar.append(but)
                but = ''
                while web[i] != '>':
                    i += 1
                i += 1
                while web[i] != '<':
                    but += web[i]
                    i += 1
                canciones.append(but)
                self.lista.Append(canciones[0], lugar[0])
                but = ''
                canciones = []
                lugar = []
                url = False
                can += 1
                if can == 10:
                    fin = True
            n += 1
 
class Descarga(wx.Panel):
    def __init__(self, panel):
        wx.Panel.__init__(self, panel)
        self.descact = False
        self.barra = wx.Gauge(self, -1, size=(297, -1))
        self.descbtn = wx.Button(self, -1, 'Descargar')
        dsc = wx.StaticBox(self, label='Lista de descarga', pos=(5, 55), size=(290, 240))
        self.listdesc = wx.ListBox(self, pos=(10, 75), size=(280, 221), style=wx.LB_SINGLE)
        topsizer = wx.BoxSizer(wx.HORIZONTAL)
        topsizer.Add(self.barra, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 3)
        middle = wx.BoxSizer(wx.HORIZONTAL)
        mid = wx.BoxSizer(wx.HORIZONTAL)
        mid.Add(wx.StaticLine(self, -1, size=(97, -1)), 0, wx.ALL|wx.EXPAND, 3)
        mid.Add(self.descbtn, 0, wx.ALL, 3)
        mid.Add(wx.StaticLine(self, -1, size=(97, -1)), 0, wx.ALL|wx.EXPAND, 3)
        foot = wx.StaticBoxSizer(dsc, wx.HORIZONTAL)
        foot.Add(self.listdesc, 0, wx.ALL, 0)
        total = wx.BoxSizer(wx.VERTICAL)
        total.Add(topsizer, 0, wx.ALL, 3)
        total.Add(middle, 0, wx.ALL, 3)
        total.Add(mid, 0, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 3)        
        total.Add(foot, 0, wx.ALL, 3)
        self.SetSizer(total)
        total.Fit(self)
        self.listdesc.Bind(wx.EVT_LEFT_DCLICK, self.eliminarlist)
        self.Bind(wx.EVT_BUTTON, self.activardesc, self.descbtn)
 
    def activardesc(self, event):
        if self.descbtn.Label == 'Descargar':
            thread.start_new_thread(self.descargar, ())
            self.descact = True
            self.descbtn.Label = 'Cancelar'
        else:
            self.descact = False
            self.descbtn.Label = 'Descargar'
 
    def descargar(self):
        #Buscamos el link de descarga y descargamos la eleccion escogida
        while self.descact:
            try:
                self.barra.Pulse()
                web = u.urlopen('http://www.videofindr.net/goear/?url=http://goear.com/%s' % self.listdesc.GetClientData(0))
                web = web.read()
                tam = len(web)
                i = web.find('http:')
                url = ''
                while web[i] != '"':
                    url += web[i]
                    i += 1
                u.urlretrieve(url, "%s.mp3" % self.listdesc.GetString(0), reporthook=self.progresodesc)
                self.listdesc.Delete(0)
                self.barra.SetRange(0)
                self.barra.SetValue(0)
            except:
                self.barra.SetRange(0)
                self.barra.SetValue(0)
                self.descact = False
                self.descbtn.Label = 'Descargar'
 
    def progresodesc(self, bloque, tamano, total):
        self.barra.SetRange(total)
        totaldesc = bloque * tamano
        self.barra.SetValue(totaldesc)
 
    def eliminarlist(self, event):
        try:
            self.listdesc.Delete(self.listdesc.GetSelection())
        except:
            pass
 
class Frame(wx.Frame):
    def __init__(self):
        #Frame en el que se veran los widgets a partir de dos pestanas
        wx.Frame.__init__(self, None, -1, title="Metafora Music Downloader", pos=wx.DefaultPosition, 
            size=(315, 390), 
            style=wx.DEFAULT_FRAME_STYLE^(wx.RESIZE_BORDER|wx. MAXIMIZE_BOX))
        panel = wx.Panel(self)
        nb = wx.Notebook(panel)
        pg1 = Busqueda(nb)
        global pg2
        pg2 = Descarga(nb)
        nb.AddPage(pg1, "Busqueda")
        nb.AddPage(pg2, "Descarga")
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(nb, 1, wx.EXPAND)
        panel.SetSizer(sizer)
        self.SetExtraStyle(wx.FRAME_EX_METAL)
        self.Center()
 
class App(wx.App):
    def OnInit(self):
        frame = Frame()
        frame.Show()
        self.SetTopWindow(frame)
        return True
 
if __name__ == '__main__':
    app = App()
 
 
 app.MainLoop()
Compartir este tema:
El 24 marzo, 2011 · 0 Comentarios
  • Compartir en Delicious
  • Compartir en Digg
  • Compartir en Linkedin
  • Compartir en MySpace
  • Compartir en Technorati
  • Compartir en Tuenti

Servlet encargado de recibir una petición GET desde un Applet de java y transmitir la información a través del puerto serial del host donde esta alojado el mismo. (Cambios mínimos en el código son requeridos).

Nombre del Programa: Servlet Serial.

Versión del Programa: NA.

Autor(es): Oswaldo Gutierrez (-Gosw-) y Widnelzy Salas (yuyiwid).

Sistema Operativos: Windows XP SP3.

Lenguaje en que fue programado: Java 1.6.x.

Licencia bajo la que fue liberado: Creative Commons Reconocimiento-NoComercial-CompartirIgual 3.0 , Ver Registro en SafeCreative.org.

Fecha de lanzamiento: 14 de Octubre del 2009.

Idioma(s): NA.

Captura de pantalla del programa ejecutándose: NA.

Código:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import javax.comm.*;
import java.net.*;
 
public class ServletSerial extends HttpServlet
{
    static Enumeration portList;
    static CommPortIdentifier portId;
    static String messageString;
    static String messageString2;
    static SerialPort serialPort;
    static OutputStream outputStream;
 
    @Override
    public void init(ServletConfig conf) throws ServletException
    {
        super.init(conf);
    }
 
    protected void processRequest(HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
    {
        respuesta.setContentType ("text/html");
	PrintWriter salida = respuesta.getWriter();
 
        Enumeration enu = peticion.getParameterNames();
        while(enu.hasMoreElements()) {
            String s_clave = enu.nextElement().toString();
            String s_aux = peticion.getParameter(s_clave);
            messageString = s_aux;
            messageString2 = s_clave;
        }
        portList = CommPortIdentifier.getPortIdentifiers();
        while (portList.hasMoreElements())
        {
            portId = (CommPortIdentifier) portList.nextElement();
            if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
            {
                if (portId.getName().equals("COM2"))
                {
                // if (portId.getName().equals("/dev/term/a")) {
                    try
                    {
                        System.setSecurityManager(new MySecurityManager());
                        serialPort = (SerialPort)portId.open("ServletSerial", 2000);
                    } catch (PortInUseException e) {}
 
                    ///////////////////////////////////////////////////////
                    try
                    {
                        outputStream = serialPort.getOutputStream();
                    } catch (IOException e) {}
                    try
                    {
                        serialPort.setSerialPortParams(9600,
                        SerialPort.DATABITS_8,
                        SerialPort.STOPBITS_1,
                        SerialPort.PARITY_NONE);
                    } catch (UnsupportedCommOperationException e) {}
                    try
                    {
                        outputStream.write(messageString.getBytes());
                    } catch (IOException e) {}
                }
            }
        }
        salida.println("Informacion Enviada Correctamente: " + messageString2 + " " + messageString);
        salida.close();
        outputStream.close();
        serialPort.close();
 
    }
    @Override
    protected void doGet(HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
    {
        processRequest(peticion, respuesta);
    }
 
    @Override
    protected void doPost(HttpServletRequest peticion, HttpServletResponse respuesta) throws ServletException, IOException
    {
        processRequest(peticion, respuesta);
    }
}

Clase de seguridad necesaria para dar permisos de uso de recursos del host al Servlet Serial:

import java.io.FileDescriptor;
import java.net.InetAddress;
import java.security.Permission;
 
public class MySecurityManager extends SecurityManager
{
    @Override
	public void checkDelete(String file)
	{
	}
 
    @Override
	public void checkPermission(Permission perm)
	{
	}
 
    @Override
	public void checkPropertyAccess(String key)
	{
	}
 
    @Override
	public void checkPropertiesAccess()
	{
	}
 
    @Override
	public void checkPermission(Permission perm, Object context)
	{
	}
 
    @Override
	public void checkAccept(String host, int port)
	{
	}
 
    @Override
	public void checkAccess(ThreadGroup g)
	{
	}
 
    @Override
	public void checkAccess(Thread t)
	{
	}
 
    @Override
	public void checkAwtEventQueueAccess()
	{
	}
 
    @Override
	public void checkConnect(String host, int port)
	{
	}
 
    @Override
	public void checkConnect(String host, int port, Object context)
	{
	}
 
    @Override
	public void checkCreateClassLoader()
	{
	}
 
    @Override
	public void checkExec(String cmd)
	{
	}
 
    @Override
	public void checkExit(int status)
	{
	}
 
    @Override
	public void checkLink(String lib)
	{
	}
 
    @Override
	public void checkListen(int port)
	{
	}
 
    @Override
	public void checkMemberAccess(Class clazz, int which)
	{
	}
 
    @Override
	public void checkMulticast(InetAddress maddr)
	{
	}
 
    @Override
	public void checkMulticast(InetAddress maddr, byte ttl)
	{
	}
 
    @Override
	public void checkPackageAccess(String pkg)
	{
	}
 
    @Override
	public void checkPackageDefinition(String pkg)
	{
	}
 
    @Override
	public void checkPrintJobAccess()
	{
	}
 
    @Override
	public void checkRead(FileDescriptor fd)
	{
	}
 
    @Override
	public void checkRead(String file)
	{
	}
 
    @Override
	public void checkRead(String file, Object context)
	{
	}
 
    @Override
	public void checkSecurityAccess(String target)
	{
	}
 
    @Override
	public void checkSetFactory()
	{
	}
 
    @Override
	public void checkSystemClipboardAccess()
	{
	}
 
    @Override
	public boolean checkTopLevelWindow(Object window)
	{
		return true;
	}
 
    @Override
	public void checkWrite(FileDescriptor fd)
	{
	}
 
    @Override
	public void checkWrite(String file)
	{
	}
}