/usr/share/cycle/cycle.py is in cycle 0.3.1-9.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | #!/usr/bin/env python
# coding: koi8-r
#====================================================
# Cycle - calendar for women
# Distributed under GNU Public License
# Author: Oleg S. Gints (altgo@users.sourceforge.net)
# Home page: http://cycle.sourceforge.net
#===================================================
import os, sys, gettext
import locale
import wxversion
wxversion.ensureMinimal('2.5.3')
import wx
import wx.html
import wx.lib.colourdb
from cal_year import *
from save_load import *
from dialogs import *
from set_dir import *
#from prn import *
import gettext
import __builtin__
lang_find=False
if not '__WXMSW__' in wx.PlatformInfo:
for lang_env_var in ('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG'):
if lang_find:
break
if os.environ.has_key(lang_env_var):
env_language=os.environ[lang_env_var]
for s_lang in env_language.split(':'): # if set more languages
os.environ[lang_env_var]=s_lang
try:
dl=locale.getdefaultlocale()
lang=[ dl[0][0:2] ]
l=gettext.translation('cycle', msg_dir, lang)
if wx.USE_UNICODE:
__builtin__.__dict__['_'] = lambda s: l.ugettext(s)
else:
__builtin__.__dict__['_'] = lambda s: l.ugettext(s).encode(dl[1])
_('try decode this string')
lang_find=True
break #language was found
except:
pass
else: #for MS Windows
try:
dl=locale.getdefaultlocale()
lang=[ dl[0][0:2] ]
l=gettext.translation('cycle', msg_dir, lang)
if wx.USE_UNICODE:
__builtin__.__dict__['_'] = lambda s: l.ugettext(s)
else:
__builtin__.__dict__['_'] = lambda s: l.ugettext(s).encode(dl[1])
_('try decode this string')
lang_find=True
except:
pass
if not lang_find:
__builtin__.__dict__['_'] = lambda s: s
lang=[""]
class MyFrame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title,
wx.DefaultPosition, wx.Size(800, 600))
wx.Image_AddHandler(wx.PNGHandler())
# self.printer = wx.HtmlEasyPrinting()
icon = wx.Icon(os.path.join(icons_dir,'mini/cycle.xpm'), wx.BITMAP_TYPE_XPM)
self.SetIcon(icon)
Val.frame=self
self.CreateStatusBar()
self.MakeToolMenu() # toolbar
self.cal=Cal_Year(self)
self.OnCurrent(self)
wx.EVT_CLOSE(self, self.OnCloseWindow)
def OnCloseWindow(self, event):
Save_Cycle(cycle.name, cycle.passwd, cycle.file)
self.Destroy()
def TimeToQuit(self, event):
self.Close(True)
def MakeToolMenu(self):
tb = self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER)
tb.SetToolBitmapSize( wx.Size(24,24) )
SetToolPath(self, tb, 10, os.path.join(bitmaps_dir,'dec.png'), _('Dec Year'))
wx.EVT_TOOL(self, 10, self.OnDecYear)
SetToolPath(self, tb, 20, os.path.join(bitmaps_dir,'curr.png'), _('Current Year'))
wx.EVT_TOOL(self, 20, self.OnCurrent)
SetToolPath(self, tb, 30, os.path.join(bitmaps_dir,'inc.png'), _('Inc Year'))
wx.EVT_TOOL(self, 30, self.OnIncYear)
tb.SetToolSeparation(50)
tb.AddSeparator()
SetToolPath(self, tb, 40, os.path.join(bitmaps_dir,'legend.png'), _('Legend'))
wx.EVT_TOOL(self, 40, self.Legend)
SetToolPath(self, tb, 45, os.path.join(bitmaps_dir,'export.png'), _('Export to iCal'))
wx.EVT_TOOL(self, 45, self.Export)
SetToolPath(self, tb, 50, os.path.join(bitmaps_dir,'set.png'), _('Settings'))
wx.EVT_TOOL(self, 50, self.Settings)
SetToolPath(self, tb, 55, os.path.join(bitmaps_dir,'help.png'), _('Help'))
wx.EVT_TOOL(self, 55, self.Info)
# SetToolPath(self, tb, 57, os.path.join(bitmaps_dir,'help.png'), _('Print'))
# wx.EVT_TOOL(self, 57, self.test)
tb.AddSeparator()
SetToolPath(self, tb, 60, os.path.join(bitmaps_dir,'exit.png'), _('Exit'))
wx.EVT_TOOL(self, 60, self.TimeToQuit)
tb.Realize()
def test(self, event):
#rpt = report_year(self.cal.year)
#self.printer.PreviewText(rpt)
#self.printer.PreviewFile('2.html')
dlg = Colour_Dlg(self)
dlg.ShowModal()
dlg.Destroy()
def Legend(self,event):
dlg = Legend_Dlg(self)
dlg.ShowModal()
dlg.Destroy()
def Export(self, event):
dlg = wx.FileDialog(self, _("Export to iCal"),
style=wx.SAVE)
if dlg.ShowModal() == wx.ID_OK:
try:
fileobj = file(dlg.GetPath(), "w")
report_year_ical(self.cal.year, fileobj)
except (IOError, OSError), err:
wx.MessageDialog(
self, str(err), _("Unable to export"), style=wx.OK).ShowModal()
def Settings(self,event):
dlg = Settings_Dlg(self)
if dlg.ShowModal() == wx.ID_OK:
self.cal.Set_Year(wx.DateTime_Today().GetYear())
dlg.Destroy()
def Info(self, event):
global lang
f_name=os.path.join(doc_dir,"README_"+lang[0]+".html")
if not os.path.isfile(f_name):
f_name=os.path.join(doc_dir,"README.html")
f = open(f_name, "r")
msg = f.read()
dlg = Help_Dlg(self, _('Help'), msg)
dlg.ShowModal()
# increment and decrement toolbar controls
def OnIncYear(self, event):
self.cal.Inc_Year()
def OnDecYear(self, event):
self.cal.Dec_Year()
def OnCurrent(self, event):
self.cal.Set_Year(wx.DateTime_Today().GetYear())
#----------------------------------------------
def SetToolPath(self, tb, id, bmp, title):
global dir_path
tb.AddSimpleTool(id, wx.Bitmap(os.path.join(dir_path, bmp), wx.BITMAP_TYPE_PNG),
title, title)
class MyApp(wx.App):
def OnInit(self):
wx.lib.colourdb.updateColourDB()
ret=first_login()
if ret=='bad_login':
return True
elif ret=='not_first':
dlg = Login_Dlg(None)
if dlg.ShowModal() == wx.ID_CANCEL:
dlg.Destroy()
return True
dlg.Destroy()
self.frame_init()
return True
def frame_init(self):
frame = MyFrame(None, -1,"")
frame.Show(True)
self.SetTopWindow(frame)
if __name__=='__main__':
locale.setlocale(locale.LC_ALL,"")
dir_path = os.getcwd()
app = MyApp(0)
app.MainLoop()
|