EAnder 16 Light Poster

Obfuscate the hell out of it. Make it so complicated that it's not worth it for someone to look at the hex values and try and figure out how it works.

EAnder 16 Light Poster

The OP just wanted to display the info they retrieved from the webpage. Is it really that hard for them to figure out that you can save the info you returned from a webpage to a file? Oh and BTW

import os
os.popen('notepad.exe file')

starts the command window in a new process so it won't halt your program.

EAnder 16 Light Poster
os.system('notepad.exe file')

works for me. Leaves the ugly command prompt window open and won't return control to python interpreter though...

EAnder 16 Light Poster

Or you could just save the data you got from website to a file and open it with os.system(). SendKeys is only available on windows(I believe) and you run into the problem of making sure the active window is notepad.

EAnder 16 Light Poster

Using FPS IDE with FPC compiler on windows xp.

EAnder 16 Light Poster
procedure Taylor(var dat: table ; cd: integer; h: real);

begin
for i:=2 to cd + 1 do
begin
dat[i,1] := dat[i,1] + (i-1)*h;
x := dat[i-1,1]; y := dat[i-1,2];
result := h * (x*exp(ln(y)/3)) +
(sqr(h)/2) * ((sqr(x)/3) * exp(-ln(y)/3 + exp(ln(y)/3)) +
((h*h*h)/6) * (-(x*x*x/9)/y) + x *exp(-ln(y)/3)) +
(sqr(h) *sqr(h)/24) * (((sqr(x)*sqr(x)/9) * exp((-5/3)*ln(y))) -
((2/3) * sqr(x)/y + exp(-ln(y)/3) );

dat[i,2] := dat[i-1,2] + result;
end;
end;

Use code tags next time. I've never seen the table variable type, but then again I don't program in pascal much. Trying to create a variable as a "table" raises an error on my compiler(FPC, without ObjFPC support). It is possible whoever wrote that piece of code(I assume you did not because you don't understand it) made a record or data type and is using that... Or it could be in a unit you are using. You should post more of the program(especially parts where the original author uses the keywords uses, record, or type).

EAnder 16 Light Poster

For that you would check to see if the string has a length of 1 or 2. Then you would iterate over the string and make sure each character of the string is a numeric ascii code(48 to 57 I believe...). Check your ascii values on an ascii table somewhere.

EAnder 16 Light Poster

Use the readln() function to get user input into a string variable. Then check the length of the string(the string should only be one character if the only numbers that are valid input are 1 2 and 3). Then check to see if that character is the ascii code of 1 2 or 3.
ex.

ReadLn(str_input);
if length(str_input) = 1 then
begin
    if str_input = '1' or str_input = '2' or str_input = '3' then
    begin
        do_stuff(str_input);
    end;
    
end else
begin
    do_otherstuff();
end;
EAnder 16 Light Poster

If by pdu you mean protocol data unit(what i get when I google "pdu"), then thats a protocol not a character set. If you mean ETSI GSM 03.38(some character set i get when I google "pdu to ascii") then here is a list of pdu characters to their corresponding unicode characters. Then it is a simple matter to convert from unicode to ascii. Remember... google is your friend.

EAnder 16 Light Poster

American Beauty, god I first heard it about a week ago. Amazing.

EAnder 16 Light Poster

Thanks. That website shows what I need to do. I cannot use pascal strings (eg. [5, 'h', 'e', 'l', 'l', 'o'] right?) instead I need to create a new datatype and functions to work that datatype for C Strings((Null terminated)?). This is what I gathered from the webpage (http://www.hu.freepascal.org/lists/f...ly/005694.html) you pointed me to. Help me out if I am wrong. Thanks a lot.
--EAnder

EAnder 16 Light Poster

I am attempting to get the username of the current user on a windows computer using windows API. I am using the GetUserName function in the Windows Unit. I am having some problems with giving the correct data types for function arguments. Any help would be greatly appreciated.

program logname;

uses
    Windows;
var
    username : array[0..255] of char;

begin
  if GetUserName(username,255) then
  begin
    WriteLn(username);
  end;
  Readln;
end.

When I run the compiled program I get a runtime error of 216 at 0x77FE1DDE.
I also get an error from my ide that the compiler does not know which function to overload.
I am using FPC and the FPS ide.
Thanks.
--EAnder

EAnder 16 Light Poster

I did something very similar for my father who happens to be a weather nut. I went online and found the webpage for our zipcode and used urllib to get updates of the webpage every 15 minutes or so. Then I just parsed the html for common things like temperature, dew point, cloud coverage. It was pretty simple once you knew what to look for. My solution worked fine for me but if you plan on sharing this program with more than you or maybe a family member I would recomend using the APIs as they will probably be more reliable. If the weather channel were to change their webpage design my little program could be useless.

--EAnder

vegaseat commented: thanks for the note +14
EAnder 16 Light Poster

You should be able to do that by changing the Registry. Remember: Google is your friend.

EAnder 16 Light Poster

My HTML kicks your C++'s ass!
I read that somewhere. lol.

EAnder 16 Light Poster

You can use the standard Tkinter module or download wxPython. There are others but those are the most popular I think. Google for tutorials.

EAnder 16 Light Poster

ha! Try to click on the images that are buttons... lol.

I also found that if you do it a second time it does it faster.

EAnder 16 Light Poster

If you are using windows you can use the third party module pyHook.

EAnder 16 Light Poster

This is a quick little hack I made for windows that works on my vista computer, no third party modules needed ;-)

import os
data = os.popen('vol '+'c:', 'r').read()
data = data.split()
return data[len(data)-1:]

I looked around quick on the web and on linux you might be able to cook up something like that using the shell command "hdparm".
GL.

EAnder 16 Light Poster

No. The win32gui.GetDesktopWindow function returns the screen size.

EAnder 16 Light Poster

Thanks for your help and sorry if I did not make this clear but I need info on the .pyc files. I know they are binary and I need to know the structure of the files and the the byte codes for each instruction. The structure is somewhat explained in this article I just found but the auther is sounding quite confused himself: http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html

Edit: Ill have to get a copy of python source code from python.org. Good idea to look into that. Hope I can understand enough of the c. thx

EAnder 16 Light Poster

I was a little bored today and I started to google how the Python Virtual Machine works. I found a bunch of helpfull articles and kind of understand at least some of the very basic PVM code using the modules py_compile and dis. I was wondering how to write the actual PVM code to a file (without writing python code to a file and compiling it with py_compile) if i wanted to generate PVM code from another language - kind of like jython and the java interpreter. Ill probably just use it to implement a simple language like brainfsck but maybe branch out if I can/have the willpower. If anybody knows or at least can help point me in the right direction your help will be greatly apreciated.

EAnder 16 Light Poster

The only thing I wanted to know if there is anything I need to know before attempting writting my Own chat program.

Sorry to damper your spirits but a good (better than ~workable) knowledge of threading would be a must, re module for filtering out curses(if you want to), file io for logs, and a working chat protocol (like IRC) to use (or create your own)...

EAnder 16 Light Poster

You may have already tried this while trying os.system but in windows (Idk about linux/others) this works:

os.system("start")

You should be able to start any application in windows just by calling: start path_to_program arguments
Also, I assume you want to open a program that uses cmd.exe.
Edit: my bad for last line... answer in title

EAnder 16 Light Poster

I know the codes not the best well written but the only problem I'm having(besides the interpreting of the macro commands, the one here is just a base for me to work on) is how the UpdateLabels.start() method returns:

Traceback (most recent call last):
  File "C:\Users\Erik\Desktop\Stuff from last Night\MouseMacro.py", line 77, in <module>
    main()
  File "C:\Users\Erik\Desktop\Stuff from last Night\MouseMacro.py", line 75, in main
    UpdateLabels().start()
  File "C:\Python30\lib\threading.py", line 446, in start
    if not self._initialized:
AttributeError: 'UpdateLabels' object has no attribute '_initialized'

This is my code:

#Python 3k
from tkinter import *
from threading import Thread

import mouse#Third Party found at http://www.python-forum.org/pythonforum/viewtopic.php?f=2&t=8976

XPOS = 0
YPOS = 0

class UpdateLabels(Thread):#activates in main...did not work?
    def __init__(self):
        global XPOS
        global YPOS
    def _initialize(self):
        run()
    def run(self):
        XPOS = mouse.getpos()[0]
        YPOS = mouse.getpos()[1]
def Help():
    messagebox._show(title="Help", message="Do This...")#add help message

def Load_Macro():#Add Lots of Error Checking here!!!!!!!!!!!!!(Make sure file exitsts!)
    f = open(filedialog.askopenfilename(), 'r')
    data = f.read()
    f.close()
    txt_Macro.delete(1.0, END)
    txt_Macro.insert(END, data)


def Interpret(text):#NEED TO FIX
    text = text.split(';')
    for i in text:
        com = i.split()
        if com[0] == 'MOV':
            #parse for move command
            b = com.split()
            mouse.move(int(b[0]), int(b[1]))
        elif com[0] == 'CLK':
            mouse.click()
        elif com[0] == 'SLD':
            #parse for where to move and speed 'slow' or 'fast'
            b = com.split()
            mouse.slide(int(b[0]), int(b[1]), b[2])
        elif com[0] == 'HOLD':
            mouse.hold()
        elif com[0] == 'RCLK':
            mouse.rightclick()
        elif com[0] == 'RHOLD':
            mouse.righthold()
        else:
            return False#returns an ERROR if messup
def start_macro():
    Interpret(txt_Macro.get(1.0, END))
    print(txt_Macro.get(1.0, END))

root = Tk()

#Use these to update mouse …
EAnder 16 Light Poster

You can always make the server aplication give a python script conditions such as calling from the shell "python MyScipt -user=USER -pass = password" and the python script will verify the username. I think the sys has a module that allows you to use conditions.

EAnder 16 Light Poster

You would have to figure out how google has their cookies. Basicly you would need the user to enter acount and password and create a cookie and put it in the cookie for the webrowser or os (Im no expert here...). Then you would use the webbrowser.open() module.

EAnder 16 Light Poster

First of all the files you are trying to access are probably restricted to admin or root. Second of all when you use the open(raw_input("File Name: ")) it should include a whether you want read/write access. Corrected code would be

open(raw_input("File Name: "), 'r')

The 'r' is saying you want to read the file, not write to it. You can also use 'w' for write, 'rb' for reading binary, and 'wb'(i think) for writing to binary.

Andrew Wiggin commented: I love your quotes. +2
EAnder 16 Light Poster

Im not into ctypes yet but I do know that in "#define HGE_VERSION 0x180" 0x180 is not just for python. It is a hex number so it should be represented in most if not all programming languages. All else fails you could do the conversion your self i guess...

EAnder 16 Light Poster

use the #python channel at the irc server at saurik.com for ipod touch and the official #python channel

EAnder 16 Light Poster

check out http://pythonce.sourceforge.net/Wikka/GUIToolkit for alist of gui toolkits for python ce. If you can't figure that out then just do a command line app.

EAnder 16 Light Poster

You could easily display html using wxpython. Use the ActiveX_IEHtmlWindow from wx. The only problem I see is that your IM client will have to tell the difference between html and regular text. For that you make a protocol. Say the first 4 letters define what type of file it is. text would be text and the rest would be displayed on the screen. html would use the ActiveX_IEHtmlWindow.

Erik Anderson

EAnder 16 Light Poster

Im confused and I need to know how to read from a tkinter textbox in order to create a text editor. Also would it be possible to have certain words colorized as you type in words? I would like to make this into a code editor possibly. Any help would be greatly apreciated.

from Tkinter import *
import tkMessageBox
import EasyDialogs #a windows port of the mac module
import sys
def Exit():
    sys.exit()
def Help():
    tkMessageBox.showinfo("Help","Created by Erik Anderson")
def ask_save():
    response = tkMessageBox.askyesno("Save?", "Would you like to save?")
    if response == True:
        File = EasyDialogs.AskFileForSave("Save File")
####################################
        text = #This Is where i need the function
####################################
        Filesave = open(File, 'w')
        Filesave.write(text)
        Filesave.close()
    elif response == False:
        pass
def new():
    ask_save()
root = Tk()
menu = Menu(root)
text = Text(root)
root.config(menu=menu)

filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=new)
filemenu.add_command(label="Open...", command=new)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=Exit)

helpmenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=Help)

Textbox = Text(root)
Textbox.pack(side=LEFT)

root.mainloop()

thx in advance!
Erik Anderson

EAnder 16 Light Poster

pyc modules are used by modules. i think they are already compiled. they do not use python, instead python uses them.

EAnder 16 Light Poster

I don't think a cross platform compiler has been made. My suggestions:
Go to the library and compile stuff on those computers
create a cross platform compiler

EAnder 16 Light Poster

Might be binary your looking at. Or encrypted stuff but Telnet is not known for standard encryptions.
Good Luck.

EAnder 16 Light Poster

Thumbs down. Bill Gates is definetly not the devil. Sure a lot of people say he makes crap os's and software but give him a break. If he made such a horrible os then why does most of the world use his products? I would bet the creator of this thread (probably a n00b h4x0r) 10 to 1 odds he's using at least one microsoft product. Sure MS charges a lot for their products and vista is pretty buggy but I would bet you anything that If mac had as many users as windows people would be ranking on them instead of microsoft for security vulnerabilities.

EAnder 16 Light Poster

To simplify your problem I suggest the urlgrabber module at: http://linux.duke.edu/projects/urlgrabber/

It also is able to show the percentage downloaded. Heres an example I found: http://thejuhyd.blogspot.com/2007/04/youtube-downloader-in-python.html

You could also use EasyDialogs(if your mac its standard, or you can use a windows port: http://www.averdevelopment.com/python/EasyDialogs.html for a gui progress bar) or Tkinter, or wxPython, or you could just create a console app that clears the screen every second or so and rewrites all the data including the new percentage.

EAnder 16 Light Poster

I am in the process of writing a brainfsck interpreter. It's just a skeleton and I still have to add Ascii, multi-character, and loops but, I was wondering was their any way I could create a compiler with python? I heard I could use lex and yacc but I am still not sure how to use them or to actually compile the bf code. Any links, modules, comments, and help would be greatly apreciated.
-EAnder

EAnder 16 Light Poster

I see AI as a program that learns from experience. Say ELIZA learned the meaning of "it", "it" would generaly mean the main object you were talking about in the last sentence. The same would aply to he,she,they... That would be a very basic in my mind AI. It would also be AI if ELIZA learned the meaning of words it did not know like... something that doesnt come up in everyday speech. ELIZA would take the sentence that the word was used and use other words to create a generic definition. If ELIZA could not it would ask the user to tell them a definition and do the same as before.

EAnder 16 Light Poster

I've noticed there is at least 1 thread regarding to artificial intelligence. I assume most people new and old to python would be interested in artificial intelligence and the even greater goal of artificial life. I personally do not know anything about them. If you have ever had any experience in either AI or AL please post some techniques, theories, examples, websites, and simple how to's.

EAnder 16 Light Poster

You should be able to do that with any http proxy server...You just need to send the correct request. I know get is to get a certain page on a site, but you could hack to gether a program that simulates entering in a textbox (when you enter a textbox (like the one im doing right now) when you press enter your browser sends a request also sending what you entered) you may have to do some research like what text box to use but you should be able to acomplish this task with only sockets for the raw necessities. GL

oh yeah you will need to learn more about the http protocol. Google it.

EAnder 16 Light Poster

1. Create a program that shutsdown/loggsoff a user after a period of inactivity.
Hint: Use the PyHook module at http://mindtrove.info/articles/monitoring-global-input-with-pyhook/ and the os module

2. Create a function that filters obcenities out of typed speech like in some IRC or AIM chatrooms.
Hint: Use the standard re module (may make it easier)

3.Ever see The Number 23? Ask a user for their age, birthday, address, name,Phone numbers etc... and see if it can find any 23's or 32's
Hint: Change letters to numbers(duh!) a = 1, b = 2, c = 3...

4. I've heard that it is possible to create a brainf*ck compiler/interpreter in python pretty easily. Try it out.
Hint: http://linuxgazette.net/issue79/divakaran.html http://en.wikipedia.org/wiki/Brainfuck

5. Create an application that allows you to chat with someone directly over the internet
Hint: you need the socket module

EAnder 16 Light Poster

AIM doesn't just allow random clients to connect to their servers. You need a authorization number that is sent to the server in order to validate the client. Once you are authorizid you can send messages. You need to download their sdk at aim.com which contains that number. The problem is that it is meant for languages like java and c# and others. If the SDK uses dll's you could use ctypes
to call them. That would be the only way to use the authorization code and the chat protocol other than learning a whole nother language.
I hope this is making sense to whoever reads this.

EAnder 16 Light Poster

To speed up Python there are 3 things you could do that I know of:

Code Smarter: As ChainSaw pointed out. Try to simplify your programs. Don't rewrite things(there is a reason why a lot of modules are written in c, c++, and D. Not because they had to but because they are already compiled). Use threads and then reuse them. Make functions. Its the same as recycling.

Psyco(Did I spell the name right?): If you are using a 64 bit processor(I'm pretty sure its limited to a 64 bit) you can use the Psyco module and that speeds it up. I've heard its easy to use even for intermediate python programmers.

Compiling: I know python is interpreted but you can compile programs with py2exe(windows) or py2app(Mac), or PyInstaller(all i think)

EAnder 16 Light Poster

You could use the urllib or urllib2 modules for this task I assume but you could also start from scratch using pure sockets. You would need to learn HTTP Protocol for this and simulate what messages a webbrowser sends to the server hosting the website for the user and password boxes.

here are some good starter websites on HTTP:
en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
www.w3.org/Protocols/
This ones really good:
http://www.jmarshall.com/easy/http/

EAnder 16 Light Poster

I am trying to add user input using the raw_input function to string url_orig. I am attempting to replace the spaces with +'s to make a 'google search'. the replace function works fine in IDE but not when I excecute the program. Any help will be appreciated

url_orig = 'http://www.google.com/search?hl=en&q='
url_add1 = ''
s.replace(' ', '+')
print s
EAnder 16 Light Poster

I know you can use this to open IE6 but i do not know if it will open html files

import webbrowser
url = http://www.google.com # I presume you can open html files
webbrowser.open(url)
EAnder 16 Light Poster

I (being a novice python programmer) would use a loop for your problem. try something like this:

user1 = 'user'
user1loop = 1
while user1loop = 1:
#some more code here to allow them to use the chat server

... later you would put in an option to perform an action to that user

print 'who would you like to boot?'
print '1) user1'
print '2) user2'
print '3)user3'
print ' 4) the rest of the users'

choice = 0
choice = input('choice: ')
if choice == 1:
        user1loop = 0
elif choice == 2:
        user2loop = 0
elif choic == 3:
        user3loop = 0
elif choice == 4:
        therestofthepeopleloop = 0

I hope this helps you. I have not tried this out and I hope it works!