Esempio n. 1
0
	def __init__(self):
		# Initialize Self.paths here.
		self.paths = dict()
		self.paths['resources'] = os.path.join(sys.path[0], "./")
		self.paths['preferences'] = ''
		self.paths['copyright'] = ''
		self.paths['main'] = ''
		self.paths['listen'] = False
		self.paths['connect'] = ''
		self.paths['list'] = []
		self.paths['mode'] = ''
		self.paths['low-colors'] = False
		
		if re.match('(?:open|free|net)bsd|linux',sys.platform):
			self.paths['main'] = os.path.join(sys.path[0], '..', 'share', 'gitso')
			self.paths['copyright'] = os.path.join(sys.path[0], '..', 'share', 'doc', 'gitso', 'COPYING')
			self.paths['locales'] = os.path.join(sys.path[0], '..','share','locale')
		elif sys.platform == "darwin":
			self.paths['main'] = sys.path[0]
			self.paths['copyright'] = os.path.join(sys.path[0], 'share', 'doc', 'gitso', 'COPYING')
			self.paths['locales'] = os.path.join(sys.path[0], 'locale')
		else:
			self.paths['main'] = os.path.join(sys.path[0], '..')
			self.paths['copyright'] = os.path.join(sys.path[0], '..', 'COPYING')
			self.paths['locales'] = os.path.join(sys.path[0],'..', 'locale')
		
		#for i in range(1, len(sys.argv)):
		i = 1
		while i < len(sys.argv):
			if sys.argv[i] == '--help': # --help
				self.HelpMenu()
			elif sys.argv[i] == '--version': # --version
				print _("Gitso %s  -- Copyright 2007 - 2014 Aaron Gerber and Derek Buranen and AustP.") % pkg_data.get_version()
				exit(0)
			elif sys.argv[i] == '--dev': # --dev
				print _("Running in 'Development Mode'")
				self.paths['mode'] = 'dev'
				if sys.platform == "darwin":
					if not os.path.exists('build/OSXvnc'):
						os.popen("mkdir build; cp arch/osx/OSXvnc.tar.gz build ; cd build ; tar xvfz OSXvnc.tar.gz > /dev/null")
					if not os.path.exists('build/cotvnc.app'):
						os.popen("cp arch/osx/cotvnc.app.tar.gz build ; cd build ; tar xvfz cotvnc.app.tar.gz > /dev/null")
						
					self.paths['resources'] = 'build/'
					self.paths['main']		= sys.path[0]
					self.paths['copyright'] = os.path.join(sys.path[0], 'COPYING')
					
				elif sys.platform == "win32":
					self.paths['copyright'] = os.path.join(sys.path[0], 'COPYING')
					self.paths['main']		= os.path.join(sys.path[0])
					self.paths['resources'] = 'arch/win32/'
					
				else:
					self.paths['resources'] = 'arch/linux/'
					self.paths['main']		= os.path.join(sys.path[0])
					self.paths['copyright'] = os.path.join(sys.path[0], 'COPYING')

			elif sys.argv[i] == '--listen': # --listen
				if self.paths['connect'] != "":
					print _("Error: --connect and --listen can not be used at the same time")
					self.HelpMenu()
				self.paths['listen'] = True

			elif sys.argv[i] == '--connect': # --connect
				i = i + 1
				if i >= len(sys.argv):
					print _("Error: No IP or domain name given")
					self.HelpMenu()

				if self.paths['listen']:
					print _("Error: --connect and --listen can not be used at the same time")
					self.HelpMenu()
				
				if sys.argv[i][0] + sys.argv[i][1] != "--":
					self.paths['connect'] = sys.argv[i]
				else:
					print _("Error: '%s' is not a valid host with '--connect'") % sys.argv[i]
					self.HelpMenu()

			elif sys.argv[i] == '--low-colors': # --low-colors
				self.paths['low-colors'] = True;

			elif sys.argv[i] == '--list': # --list
				i = i + 1
				if i >= len(sys.argv):
					print _("Error: No List file given")
					self.HelpMenu()
				
				if sys.argv[i][0] + sys.argv[i][1] != "--":
					self.paths['list'] = self.getHosts(sys.argv[i])
				else:
					print _("Error: '%s' is not a valid list with '--list'") % sys.argv[i]
					self.HelpMenu()

			else:
				print _("Error: '%s' is not a valid argument") % sys.argv[i]
				self.HelpMenu()

			i = i + 1
		
		if sys.platform == "darwin":
				self.paths['preferences'] = os.path.join(os.path.expanduser("~"), "Library", "Application Support", "Gitso")
				if os.path.exists(self.paths['preferences']) != True:
						os.makedirs(self.paths['preferences'], 0700)
				self.paths['preferences'] = os.path.join(self.paths['preferences'], "hosts")
		elif sys.platform == "win32":
				self.paths['preferences'] = os.path.join(os.getenv('USERPROFILE'), "gitso-hosts")
		else:
				self.paths['preferences'] = os.path.join(os.path.expanduser("~"), ".gitso-hosts")
Esempio n. 2
0
    def __init__(self, parent, id, title, paths):
        """
		Setup About Window for Gitso
		
		@author: Derek Buranen
		@author: Aaron Gerber
		"""
        wx.Frame.__init__(self,
                          parent,
                          wx.ID_ANY,
                          title,
                          size=(525, 400),
                          style=wx.CLOSE_BOX | wx.MINIMIZE_BOX)

        if sys.platform == 'win32':
            self.SetBackgroundColour(wx.Colour(236, 233, 216))

        icon = wx.Icon(os.path.join(paths['main'], 'gitso.ico'),
                       wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        ## Headings ##
        text1 = wx.StaticText(self, wx.ID_ANY, 'Gitso')
        font1 = wx.Font(24, wx.NORMAL, wx.NORMAL, wx.BOLD)
        text1.SetFont(font1)

        text2 = wx.StaticText(self, -1, _("Gitso is to Support Others"))
        text3 = wx.StaticText(self, -1,
                              _("Version %s") % pkg_data.get_version())
        font2 = wx.Font(16, wx.NORMAL, wx.NORMAL, wx.NORMAL)
        font3 = wx.Font(12, wx.NORMAL, wx.NORMAL, wx.NORMAL)
        text2.SetFont(font2)
        text3.SetFont(font3)
        url = wx.HyperlinkCtrl(self, -1, "github.com/AustP/Gitso",
                               "https://github.com/AustP/Gitso")

        data = open(os.path.join(paths['main'], 'gitso.png'), "rb").read()
        stream = cStringIO.StringIO(data)
        img = wx.ImageFromStream(stream)
        img.Rescale(150, 150)
        bmp = wx.BitmapFromImage(img)
        image1 = wx.StaticBitmap(self, -1, bmp)

        ## Buttons ##
        ok = wx.Button(self, wx.ID_OK, "OK")
        self.SetDefaultItem(ok)
        ok.SetFocus()
        wx.EVT_BUTTON(self, wx.ID_OK, self.CloseAbout)

        ## Sizers ##
        topsizer = wx.BoxSizer(wx.VERTICAL)

        info_sizer = wx.BoxSizer(wx.VERTICAL)
        info_sizer.Add(text1, 0, wx.ALIGN_CENTER | wx.ALL, 7)
        info_sizer.Add(text2, 0, wx.ALIGN_CENTER | wx.ALL, 3)
        info_sizer.Add(text3, 0, wx.ALIGN_CENTER | wx.ALL, 3)
        info_sizer.Add(url, 0, wx.ALIGN_CENTER | wx.ALL, 3)

        heading_sizer = wx.BoxSizer(wx.HORIZONTAL)
        heading_sizer.Add(image1, 0, wx.ALIGN_LEFT | wx.ALL, 10)
        heading_sizer.Add(info_sizer, 0, wx.ALL, 10)

        topsizer.Add(heading_sizer, 0, wx.ALIGN_CENTER)

        ## Tabs ##
        nb = wx.Notebook(self, size=wx.Size(525, 220))

        license_page = LicensePage(nb, paths)
        info_page = InfoPage(nb)

        nb.AddPage(info_page, _("Authors"))
        nb.AddPage(license_page, _("License"))

        tab_sizer = wx.BoxSizer(wx.HORIZONTAL)
        tab_sizer.Add(nb, 1, wx.EXPAND | wx.ALL, 10)
        topsizer.Add(tab_sizer, 1, wx.ALIGN_RIGHT)

        ## Buttons ##
        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button_sizer.Add(ok, 0, wx.ALL, 10)
        topsizer.Add(button_sizer, 0, wx.ALIGN_RIGHT)

        ## Final settings ##
        self.SetSizer(topsizer)
        topsizer.SetSizeHints(self)

        self.SetThemeEnabled(True)
        self.Centre()
        self.Show()
Esempio n. 3
0
	def __init__(self, parent, id, title, paths):
		"""
		Setup About Window for Gitso
		
		@author: Derek Buranen
		@author: Aaron Gerber
		"""
		wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=(525,400), style=wx.CLOSE_BOX | wx.MINIMIZE_BOX)
		
		if sys.platform == 'win32':
			self.SetBackgroundColour(wx.Colour(236,233,216))

		icon = wx.Icon(os.path.join(paths['main'], 'gitso.ico'), wx.BITMAP_TYPE_ICO)
		self.SetIcon(icon)

		## Headings ##
		text1 = wx.StaticText(self, wx.ID_ANY, 'Gitso')
		font1 = wx.Font(24, wx.NORMAL, wx.NORMAL, wx.BOLD)
		text1.SetFont(font1)

		text2 = wx.StaticText(self, -1, _("Gitso is to Support Others"))
		text3 = wx.StaticText(self, -1, _("Version %s") % pkg_data.get_version())
		font2 = wx.Font(16, wx.NORMAL, wx.NORMAL, wx.NORMAL)
		font3 = wx.Font(12, wx.NORMAL, wx.NORMAL, wx.NORMAL)
		text2.SetFont(font2)
		text3.SetFont(font3)
		url = wx.HyperlinkCtrl(self, -1, "github.com/AustP/Gitso", "https://github.com/AustP/Gitso")
		
		data = open(os.path.join(paths['main'], 'gitso.png'), "rb").read()
		stream = cStringIO.StringIO(data)
		img = wx.ImageFromStream(stream)
		img.Rescale(150, 150)
		bmp = wx.BitmapFromImage(img)
		image1 = wx.StaticBitmap(self, -1, bmp)
		
		## Buttons ##
		ok = wx.Button(self, wx.ID_OK, "OK")
		self.SetDefaultItem(ok)
		ok.SetFocus()
		wx.EVT_BUTTON(self, wx.ID_OK, self.CloseAbout)
		
		## Sizers ##
		topsizer = wx.BoxSizer(wx.VERTICAL);

		info_sizer = wx.BoxSizer(wx.VERTICAL);
		info_sizer.Add(text1, 0, wx.ALIGN_CENTER | wx.ALL, 7);
		info_sizer.Add(text2, 0, wx.ALIGN_CENTER | wx.ALL, 3);
		info_sizer.Add(text3, 0, wx.ALIGN_CENTER | wx.ALL, 3);
		info_sizer.Add(url, 0, wx.ALIGN_CENTER | wx.ALL, 3);

		heading_sizer = wx.BoxSizer(wx.HORIZONTAL);
		heading_sizer.Add(image1, 0, wx.ALIGN_LEFT | wx.ALL, 10 );
		heading_sizer.Add(info_sizer, 0, wx.ALL, 10 );

		topsizer.Add(heading_sizer, 0, wx.ALIGN_CENTER);

		## Tabs ##
		nb = wx.Notebook(self, size=wx.Size(525,220))
		
		license_page = LicensePage(nb, paths)
		info_page = InfoPage(nb)
		
		nb.AddPage(info_page, _("Authors"))
		nb.AddPage(license_page, _("License"))
		
		tab_sizer = wx.BoxSizer(wx.HORIZONTAL);
		tab_sizer.Add(nb, 1, wx.EXPAND | wx.ALL, 10 );
		topsizer.Add(tab_sizer, 1, wx.ALIGN_RIGHT );

		## Buttons ##
		button_sizer = wx.BoxSizer(wx.HORIZONTAL);
		button_sizer.Add(ok, 0, wx.ALL, 10 );
		topsizer.Add(button_sizer, 0, wx.ALIGN_RIGHT );

		## Final settings ##
		self.SetSizer(topsizer);
		topsizer.SetSizeHints(self);

		self.SetThemeEnabled(True)
		self.Centre()
		self.Show()