~ubuntu-branches/debian/wheezy/playonlinux/wheezy

« back to all changes in this revision

Viewing changes to python/wrapper.py

  • Committer: Bazaar Package Importer
  • Author(s): Bertrand Marc
  • Date: 2011-09-17 11:14:44 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20110917111444-b02ft5g75aljjkrp
Tags: 4.0.12-1
* New upstream release (Closes: #639558).
* Remove patches/license.diff, not necessary any more.
* debian/rules: remove permission fixing.
* debian/rules: add build-arch and build-indep.
* Migrate to dh_python2.
* debian/patches: disable update alert on new release
  (Closes: #639463).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# Copyright (C) 2011 Pâris Quentin
 
5
 
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 2 of the License, or
 
9
# (at your option) any later version.
 
10
 
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
# GNU General Public License for more details.
 
15
 
 
16
# You should have received a copy of the GNU General Public License along
 
17
# with this program; if not, write to the Free Software Foundation, Inc.,
 
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 
19
 
 
20
# Wrapper.py - Enable running PlayOnLinux and PlayOnMac scripts outside of POL/POM environement
 
21
 
 
22
encoding = 'utf-8'
 
23
 
 
24
import os, getopt, sys, urllib, signal, string, time, webbrowser, gettext, locale, sys, shutil, subprocess
 
25
import wx
 
26
        
 
27
import lib.Variables as Variables, lib.lng as lng
 
28
import guiv3 as gui, install, options, wine_versions as wver, sp, configure, threading
 
29
 
 
30
lng.Lang()
 
31
 
 
32
 
 
33
polid=os.environ["POL_ID"]
 
34
 
 
35
class Program(threading.Thread):
 
36
        def __init__(self):
 
37
                threading.Thread.__init__(self)
 
38
                self.start()
 
39
                
 
40
        def run(self):
 
41
                self.running = True
 
42
                self.chaine = ""
 
43
                for arg in sys.argv[2:]:
 
44
                        self.chaine+=" \""+arg+"\""
 
45
                self.proc = subprocess.Popen("bash \""+sys.argv[1]+"\""+self.chaine, shell=True)
 
46
                while(self.running == True):
 
47
                        self.proc.poll()
 
48
                        time.sleep(1)
 
49
                
 
50
                
 
51
class PlayOnLinuxApp(wx.App):
 
52
        def OnInit(self):
 
53
                lng.iLang()
 
54
                
 
55
                
 
56
                self.SetClassName(os.environ["APPLICATION_TITLE"])
 
57
                self.SetAppName(os.environ["APPLICATION_TITLE"])
 
58
                self.frame = gui.POL_SetupFrame(os.environ["APPLICATION_TITLE"],str(pid_to_open),top,left,str(pid_to_open))
 
59
                self.frame.Center(wx.BOTH)
 
60
                self.frame.Show(True)
 
61
 
 
62
                
 
63
                return True
 
64
 
 
65
prog = Program()
 
66
pid_to_open = -1
 
67
left = None
 
68
top = None
 
69
while(True):
 
70
        time.sleep(1)
 
71
        if(prog.proc.returncode == None):
 
72
                fichier_index = os.environ["REPERTOIRE"]+"/configurations/guis/index_"+polid
 
73
                fichier_index = os.environ["REPERTOIRE"]+"/configurations/guis/index_"+os.environ["POL_ID"]
 
74
                #print(fichier_index)
 
75
                try:
 
76
                        message = open(fichier_index,'r').read()
 
77
                except:
 
78
                        open(fichier_index,'a').write('')
 
79
                        message = open(fichier_index,'r').read()
 
80
                message = string.split(message, "\n")
 
81
                if(message[0] == "Open"):
 
82
                        pid_to_open = message[1]
 
83
                        top = message[2]
 
84
                        left = message[3]
 
85
                        app = PlayOnLinuxApp(redirect=False)
 
86
                        app.MainLoop()
 
87
        else:
 
88
                prog.running = False
 
89
                os._exit(0)
 
90
        #time.sleep(1)