How does http://qwebirc.org/ work? [closed] - python

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I think it's a really cool script. But when you're in a chat I'd like to know how it requests new chat content.
I'm interested because the chats I've made in the past have been inefficient and consumed a lot of bandwidth. I tried inspecting element in Chrome and going to Network but it never shows any requests for me. Does it use pull requests, does it use a comet sort of interface? If push, I thought this was a bad idea in PHP because each user's request creates a new PHP process or thread.
Thanks!
Someone Learning

You can download the code powering the site.
You can also browse the code
To answer your question, you should install it, and use firebug to look at network traffic.
So... you've tagged this as PHP, but you might want to edit it and tag python.
What do I need to run qwebirc?
You need Python (at least version 2.5) and Twisted (at least version 8.2.0).
On Windows you also require pywin32.
Though qwebirc will work without them, it is highly recommended that you also have Java and Mercurial.
What does qwebirc run on?
The backend should run on anything that supports Python and Twisted, it has been tested on Linux, FreeBSD and Windows (XP and above).
qwebirc is developed for QuakeNet's ircd: snircd; people have reported success on ircu and its derivatives, hyperion, charybdis, ratbox and UltimateIRCd, and in theory it should work on any RFC 1459 compliant ircd.
The frontend is tested on IE6, IE7, IE8, Firefox 3, Opera 10, Safari and Chrome.
How do I get started?
First make sure you've read the question above and you have everything required installed!
Copy config.py.example to config.py, and edit it to fit your setup.
Run compile.py to generate the HTML, minify the Javascript/CSS and copy everything to the correct locations.
Run run.py (if you get an error about the select reactor being already registered just run it again) -- note run.py has lots of arguments, you can see them with --help.
Browse to http://yourmachine:9090/

Related

Authenticating a Minecraft Microsoft account with Python

What even am I doing
So, as Minecraft Java has been slowly switching over to using Microsoft based accounts instead of solely Mojang accounts, I have been trying to put together an authentication method for a small launcher project I've been working on.
The First Issue.
I've been following a piece of documentation here, which had instructions on what GET and POST requests to send to which URLs, and how to parse them, etc. It's worked pretty well, except for The First Issue.
It was a dark and stormy night, and the Microsoft Authentication URL used Javascript for redirects, so the Requests library I was using in Python could not follow the redirects. There might be a way to parse the HTML content and find the redirections or something, but that is way above my head, because I am still new to even Python.
So I looked around for a solution that would let me follow the JavaScript redirects, and the best solution (in concept) looked to be using a headless browser. This led me down a long path until I came face to face with The Second Issue.
The Second Issue.
I looked around for a headless browser that I could use, and I found a couple:
Selenium, or
PyQT WebEngine or WebKit
(I know there are lots of others but I chose these and used them for examples)
From here, the issue isn't so much an issue to fix, but the issue of I don't know what I'm doing.
I looked into Selenium, and it looked promising, but the fact that I had to download a WebDriver confused me in terms of how I would package that, since this is going to be used for a distributed application.
I then looked into PyQT WebEngine, and it just confused me in all respects, so basically I just need some info on maybe how to use it. I also don't need to have to use PyQT to launch a window, or design my UI, or anything else. I already am planning to use Kivy for the GUI. I just need a headless browser or some other solution to follow Javascript redirects when sending a POST request to a certain URL.
So,
From here I just want to ask advice on which route I should take, since there seems to be a broad amount of options I could use. I've already mentioned what I need, so any advice on how or what I should use, in terms of headless browsers, libraries, etc.
Also if anyone has any other suggestions for how to authenticate a Microsoft account, please let me know.
I'm almost done
If there is anything I could answer or clarify, just let me know. I will highly appreciate all advice or suggestions.
Thanks,
Pyrotex7
Well to resolve this - I just went with PyQt in the end after messing around for a while.

How do I generate the Minecraft launch command for versions 1.8+ in Python?

I am currently working on a little Python project that will function as a custom and highly-configurable launcher for the popular game Minecraft to practice new skills I have been learning recently! However, I am having one problem really throwing me for a loop, and it's just how Minecraft goes about launching the actual game. From my extensive searching, I have learned that the new Minecraft login system sends the user's username and password to authserver.mojang.com/authenticate (the endpoint changing depending on just what is being done) and is returned with an access token, which can be used to log into the game.
(Edit:) What I am asking of you guys is how I would transform the data about where the game is installed and the data received from the POST request into a command that launches the game, alike how it is done in the default launcher. Overnight, I considered looked into the source of the FTB launcher and found this. This is the class for creating this launch command. How could I recreate this in Python?
Note, this question is not a duplicate, the potential duplicates in question are here and here. Both of these questions are relevant to the old launcher, but the new launcher uses a much different process.
Additionally, I have tried the strategy found here. This does not appear to work correctly on later versions, however. Edit: There was a small detail regarding the natives folder I missed. Basically, if I rename the folder to make a static copy, I can then change the natives directory in the command. However, the command still cannot be generated this way for various users.
If anyone has any ideas about this, feedback is much appreciated! Thanks!

Web interface for a Python code [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
first, English is not my native language, so, forgive me for any mistake.
I don't want to make a evasive question, so i will detail my scenario and make my point below:
I need to make a Web interface to take a information from a html's form field. Specifically a text file. Then, i need to give this file as a paramater to a Python Script that will run on my Linux server (the same who was the Web interface). I have the script running okay, have the Web interface ready, but i didn't get the point to make the web stuff works.
I'm stuck on the part of "make the wweb form talks with python script".
I tried some linux commands and some tips found on my research, but didn't work.
The goal of this thing, is to not send the Python code to end-user. So, the clients will "use" the code from a web interface and will not see the Python code responsable for make the hole stuff works.
Does anyone ever seen this kind of implementation?? Any help or information will be nice ! Tks a lot !
You should probably start with this page from the Python documentation - http://docs.python.org/howto/webservers.html. This may give you some ideas about how this works, and depending on what you need you may then continue reading about more detailed topics. Solution will depend on your plans for further development (will you extend the logic of this application? will you connect to the DB, etc.), security concerns, etc.
For only the case you define, it sounds like some simple solution will work for you, like having a simple CGI script ( http://docs.python.org/library/cgi.html), and you probably don't (yet) need anything powerful like Django or TurboGears.
For CGI to work, you will need to configure Apache web server, enable CGI for it, and then implement the CGI script utilizing your already implemented program.
You may check on the web how to do each of those steps. For example, right here, on stackoverflow: How do you set up Python scripts to work in Apache 2.0?
In your CGI script, you will need to implement some logic which will allow users to upload files to your server. You may check this page for that: http://code.activestate.com/recipes/273844-minimal-http-upload-cgi/
Finally, if with time you plan to further develop your application, you may want to look to something like Django or TurboGears. The more complex your application is - the better it is to use some web framework. You will probably spend more time studying those, but in the end you get much more power with them, and you get the code which is much more easier to maintain compared to CGI scripts. But, just as I said - it depends on your needs. (Although studying them is a good idea anyway ;) )

Python, safe, sandbox [duplicate]

This question already has answers here:
How can I sandbox Python in pure Python?
(7 answers)
Closed 9 years ago.
I'd like to make a website where people could upload their Python scripts. Of course I'd like to execute those scripts. Those scripts should do some interesting work. The problem is that people could upload scripts that could harm my server and I'd like to prevent that. What is the option to run arbitrary scripts without harming my system - actually without seeing my system at all? Thank you
"Can't be done."
Running arbitrary (untrusted) scripts and staying safe is a contradiction. You should go as far as using custom kernels, jails, vms, the like.
You can look at how http://codepad.org/about does it, it's a lot of work.
I dont know in earlier versions, in Python 3 you can create functions with access to a custom scope through types.FunctionType.
def f():
return __builtins__
f() # this will work because it has access to __builtins__
scope = {}
sandboxed = FunctionType(f.__code__,scope)
sandboxed() # will throw NameError, builtins is not defined
the returned function has only access to whatever you supplied in the scope dictionary. I wonder if still there are hacks around this.
there are quite a lot of web-server running untrusted python codes nowadays:
http://codepad.org/ (probably the most notorious pastebin for python codes)
http://codingbat.com/ (previously Javabat, name change to reflect Python addition)
http://appengine.google.com/ (host python code on Google's infrastructure)
http://www.spoj.pl/ the infamous Sphere Online Judge coding challenge
you may want to look at how they approached their problems.
or you may want to look at a different approach:
http://pyjs.org/ - pyjamas - python-to-javascript compiler (running client-side, switch the security problem to their side)
"Can't be done," is too harsh. JavaScript engines live in your web browser and they accept and run untrusted scripts safely. There's always the possibility of exploits, but in correct engine operation they are innocuous. There are even "slow script" checks that prevent infinite loops from denial-of-service attacking your browser, making those little alert dialogs.
Google App Engine runs a sandboxed version of the Python VM which effectively removes all the naughty native bits that let you get at the underlying system. To do this yourself in a safe manner would take some Python VM expertise.
For sanity, you could start off by removing all builtins and whitelisting the ones you want to allow users once you certify they don't touch the underlying system.
It feels like something somebody must have already done, but I don't know of any existing project that does it. :-/
I think the way to do this is to run those scripts in normal Python shell, but on a virtual machine. I might be biased, because my "job" is currently to play around with VMs (universities are great!).
A new VM instance can be created and started in seconds. If you keep a few around and replace only those that get broken, you have good service, absolute security and almost no effort.
But there is one thing: Virtually all web hosts today are virtual machines and they don't support another virtual machine inside. You need a real, physical server to do this.
Brett Cannon has a tentative design for doing this, last I knew, but it has not been developed. So unless you're looking to put a LOT of effort into making this happen, there currently isn't a solution publicly available.
Brett's blog is at: http://sayspy.blogspot.com/ if you want to try to read up on it, I couldn't find a direct link to his discussions about the new security design. I can't recall if I read his blog talking about it, or if it was in person where he mentioned it, sorry.
There used to be some restricted execution abilities, but they were dropped because they just didn't work.
It's not impossible to do, but it's not something that Python is able to do right now. It's something people would like, but it's not really a high priority from what I've seen.
trypython.org (BSD licensed source here) does a safe browser oriented version of such a sanbox in IronPython (via Silverlight/Moonlight). You may be able to mash together a headless version of this for use on a server -- but you could definitely let users distribute scripts between each other, or you could distribute these scripts to be executed within the plugin environment.
If you use Linux maybe seccomp is the solution, even the mode 2 is nicer. With those you can create a new process that will fail any syscall and can only read already existing file descriptors.
Maybe using also namespaces and cgroup would help, this can be done with ctypes.
You could try Ideone API - it allows Python 2 and Python 3

Simple non-web based bug tracker [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
There's a ton and and a half of questions and even more answers here concerning people looking for bug trackers. However all of them (that I found) seem to be about web based solutions. Since I'm working on a local project where I don't want to set up a web / DB server, and I don't want to use a hosted tracker either, I'm looking for something that runs locally.
very preferably open-source
pure Python or (at least) Windows executable
no need for a database server (sqlite is obviously fine)
Doesn't have to be fancy, just the basic bug / issue tracking functionality; just a little bit more than my current TODO text file or an Excel table.
Any suggestions?
I'm surprised nobody has mentioned Roundup.
It meets all your criteria, including not requiring a web-based interface (as per your specification, and unlike the accepted answer which suggested Trac).
Roundup is:
Open source
Pure Python
Supports SQLite
Not fancy, focuses on solid bug tracking
And as a significant point of differentiation, it has command-line and email interfaces in addition to a web interface.
It's very easy to get started - I suggest you take it for a spin.
Trac might be a bit too over engineered, but you could still run it locally via tracd on localhost.
It's:
opensource.
pure Python
uses sqlite
But as I said, might be too complex for your use case.
Link: http://trac.edgewall.org
If you don't need to share your bug tracker system with a team (i.e., it's okay to have it isolated to your computer) I would recommend using Tiddlywiki. Technically it's web-based, but it's entirely encapsulated within a single HTML document and requires no database or server whatsoever (only a web browser) so I think it follows the spirit of what you are wanting. It's extremely customizable since it's 100% HTML/CSS/javascript. I have been using a tiddlywiki as a project notebook for years, keeping track of my to-do list, bug list, and general project documentation in one centralized, cross-referenced place. You can also find all sorts of tiddlywikis that you can download pre-configured for productivity (for example, TeamTasks, MonkeyGTD, or GTDTiddlyWiki Plus).
Maybe Fossil is of any use to you?
It is actually a DVCS but it also integrates a bugtracker and wiki, very much like trac (although I like trac, don't get me wrong). And its webbased, on the other hand the installation is supossedly dead simple.
Proprietary TestTrack (http://www.seapine.com/ttpro.html) has a client edition that will those things. We use it at work and I'm very happy using it.
Maybe you can check out this wikipedia article for hints
http://en.wikipedia.org/wiki/Comparison_of_issue_tracking_systems
Do yourself a favor. Get over this "must not be web based" obsession, Install a local WAMP stack on your PC or on a LAN server. Now, you can install your own wiki. And something like Trac. I'd like to find an implementation of google code's bugtracker and integrated wiki thats runnable locally - Trac seems to be the closest.
You have also installed a local SVN server? Even for personal projects the ability to track changes over time. revert etc. and integration with Trac are too good to pass up even for purely 1 man projects.

Categories