Permalink
Browse files

Resuscitated and put into version control

  • Loading branch information...
mankuthimma committed Sep 22, 2011
0 parents commit d40cc943be40130b596d6ffdcfcccfcb1f08ca79
Showing with 2,212 additions and 0 deletions.
  1. 0 __init__.py
  2. +41 −0 bin/smb-client.py
  3. +22 −0 lib/__init__.py
  4. +101 −0 lib/sambashares.py
  5. +11 −0 manage.py
  6. 0 manager/__init__.py
  7. +9 −0 manager/models.py
  8. +162 −0 manager/views.py
  9. +26 −0 media/css/blueprint/ie.css
  10. BIN media/css/blueprint/plugins/buttons/icons/cross.png
  11. BIN media/css/blueprint/plugins/buttons/icons/key.png
  12. BIN media/css/blueprint/plugins/buttons/icons/tick.png
  13. +32 −0 media/css/blueprint/plugins/buttons/readme.txt
  14. +97 −0 media/css/blueprint/plugins/buttons/screen.css
  15. +14 −0 media/css/blueprint/plugins/fancy-type/readme.txt
  16. +71 −0 media/css/blueprint/plugins/fancy-type/screen.css
  17. BIN media/css/blueprint/plugins/link-icons/icons/doc.png
  18. BIN media/css/blueprint/plugins/link-icons/icons/email.png
  19. BIN media/css/blueprint/plugins/link-icons/icons/external.png
  20. BIN media/css/blueprint/plugins/link-icons/icons/feed.png
  21. BIN media/css/blueprint/plugins/link-icons/icons/im.png
  22. BIN media/css/blueprint/plugins/link-icons/icons/pdf.png
  23. BIN media/css/blueprint/plugins/link-icons/icons/visited.png
  24. BIN media/css/blueprint/plugins/link-icons/icons/xls.png
  25. +18 −0 media/css/blueprint/plugins/link-icons/readme.txt
  26. +40 −0 media/css/blueprint/plugins/link-icons/screen.css
  27. +10 −0 media/css/blueprint/plugins/rtl/readme.txt
  28. +109 −0 media/css/blueprint/plugins/rtl/screen.css
  29. +30 −0 media/css/blueprint/print.css
  30. +251 −0 media/css/blueprint/screen.css
  31. +49 −0 media/css/blueprint/src/forms.css
  32. +212 −0 media/css/blueprint/src/grid.css
  33. BIN media/css/blueprint/src/grid.png
  34. +59 −0 media/css/blueprint/src/ie.css
  35. +85 −0 media/css/blueprint/src/print.css
  36. +38 −0 media/css/blueprint/src/reset.css
  37. +105 −0 media/css/blueprint/src/typography.css
  38. +45 −0 media/css/cmxform.css
  39. +55 −0 media/css/cmxformTemplate.css
  40. +35 −0 media/css/core.css
  41. +61 −0 media/css/reset.css
  42. BIN media/images/bg.gif
  43. BIN media/images/checked.gif
  44. BIN media/images/cmxform-divider.gif
  45. BIN media/images/cmxform-fieldset.gif
  46. BIN media/images/loading.gif
  47. BIN media/images/unchecked.gif
  48. +32 −0 media/js/jquery.js
  49. +16 −0 media/js/jquery.validate.js
  50. +78 −0 settings.py
  51. +50 −0 smb-pyro.py
  52. +2 −0 startup
  53. +74 −0 templates/manager/edit.html
  54. +72 −0 templates/manager/form.html
  55. +43 −0 templates/manager/index.html
  56. +32 −0 templates/manager/modify.html
  57. +25 −0 urls.py
No changes.
@@ -0,0 +1,41 @@
+##
+## smb-client.py
+## Author : <shashi@inf.in>
+## Started on Tue Dec 2 14:13:31 2008 Shashishekhar S
+## $Id$
+##
+## Copyright (C) 2008 INFORMEDIA
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+
+import Pyro.util
+import Pyro.core
+
+Pyro.core.initClient()
+
+sc = Pyro.core.getProxyForURI("PYRONAME://:smbshare.op")
+
+s = sc.addshare('SHARE-ONE', 'Example Share', 'one', 'office')
+s = sc.remshare('SHARE-ONE')
+#t = sc.modshare('Backup', 'For Backup', 'backup', 'bigbang')
+print sc.listshares()
+
+# import ldap
+# l = ldap.initialize("ldap://192.168.1.5")
+# l.simple_bind_s("","")
+# d = l.search_s("dc=intra,dc=ncf-india,dc=org", ldap.SCOPE_SUBTREE, "objectClass=posixGroup", ['displayName','memberUid'])
+# print d
+
+
@@ -0,0 +1,22 @@
+##
+## __init__.py
+## Author : <shashi@inf.in>
+## Started on Tue Dec 2 16:51:31 2008 Shashishekhar S
+## $Id$
+##
+## Copyright (C) 2008 INFORMEDIA
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+
@@ -0,0 +1,101 @@
+##
+## samba-shares.py
+## Author : <shashi@inf.in>
+## Started on Tue Dec 2 11:29:05 2008 Shashishekhar S
+## $Id$
+##
+## Copyright (C) 2008 INFORMEDIA
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+
+from configobj import ConfigObj, SimpleVal
+
+class SambaShares:
+
+ def __init__(self):
+ pass
+
+ def addshare(self, name, comment, path, group):
+ _smb = '/var/tmp/smb.conf'
+ self.cfg = ConfigObj(_smb)
+ cfg = self.cfg
+ section = {
+ 'comment': comment,
+ 'path': '/store/'+path,
+ 'writable': 'yes',
+ 'browseable': 'yes',
+ 'create mask': '0765',
+ 'valid users': '@'+group,
+ 'public': 'yes'
+ }
+ cfg[name] = section
+ cfg.write()
+ return True
+
+ def listshares(self):
+ _smb = '/var/tmp/smb.conf'
+ self.cfg = ConfigObj(_smb)
+
+ cfg = self.cfg
+ shares = []
+ for k in cfg.keys():
+ if (k != 'global'):
+ try:
+ shares.append({'name': k, 'group': cfg[k]['valid users'].replace('@',''), 'path': cfg[k]['path'].replace('/store/','').replace('/','')})
+ except KeyError:
+ pass
+ return shares
+
+ def remshare(self, name):
+ _smb = '/var/tmp/smb.conf'
+ self.cfg = ConfigObj(_smb)
+
+ cfg = self.cfg
+ cfg.pop(name)
+ cfg.write()
+ return True
+
+ def modshare(self, name, comment, path, group):
+ _smb = '/var/tmp/smb.conf'
+ self.cfg = ConfigObj(_smb)
+
+ cfg = self.cfg
+ cfg[name]['comment'] = comment
+ cfg[name]['path'] = '/store/'+path
+ cfg[name]['valid users'] = '@'+group
+ cfg.write()
+ return True
+
+ def getshare(self, name):
+ _smb = '/var/tmp/smb.conf'
+ self.cfg = ConfigObj(_smb)
+ r = {}
+ if self.cfg.has_key(name):
+ r['name'] = name
+ r['comment'] = self.cfg[name]['comment']
+ r['path'] = self.cfg[name]['path'].replace('/store/','').replace('/','')
+ r['group'] = self.cfg[name]['valid users'].replace('@','')
+ return r
+
+
+if __name__ == "__main__":
+ c = SambaShares()
+ s = c.addshare('SHARE-ONE', 'Example Share', 'one', 'office')
+ print c.listshares()
+ s = c.remshare('SHARE-ONE')
+ print c.listshares()
+# t = c.modshare('Backup', 'For Backup', 'backup', 'bigbucks')
+ print c.listshares()
+
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+ import settings # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.exit(1)
+
+if __name__ == "__main__":
+ execute_manager(settings)
No changes.
@@ -0,0 +1,9 @@
+from django.db import models
+
+class Share(models.Model):
+ name = models.CharField(max_length=200)
+ comment = models.CharField(max_length=200)
+ path = models.CharField(max_length=100)
+ valid_users = models.CharField(max_length=100)
+
+
@@ -0,0 +1,162 @@
+from django.shortcuts import render_to_response
+from django.http import HttpResponse, HttpResponseRedirect
+from django.core.urlresolvers import reverse
+import Pyro.util
+import Pyro.core
+import ldap
+
+Pyro.core.initClient()
+
+def index(request):
+
+ # Shares
+ sc = Pyro.core.getProxyForURI("PYRONAME://:smbshare.op")
+ shares = sc.listshares()
+
+ # Groups
+ l = ldap.initialize("ldap://192.168.1.5")
+ l.simple_bind_s("","")
+ g = l.search_s("dc=intra,dc=informedia,dc=in", ldap.SCOPE_SUBTREE, "objectClass=posixGroup", ['displayName','memberUid'])
+
+ groups = []
+ for ele in g:
+ tp = {}
+ if (ele[1].has_key('displayName') and ele[1]['displayName'][0] == ""):
+ continue
+ if (ele[1].has_key('displayName')):
+ tp['name'] = ele[1]['displayName'][0]
+ if (ele[1].has_key('memberUid')):
+ tp['members'] = ele[1]['memberUid']
+ groups.append(tp)
+
+ return render_to_response('manager/index.html', {'shares': shares,'groups': groups})
+
+
+def remove(request, sharename=None):
+
+ # Shares
+ sc = Pyro.core.getProxyForURI("PYRONAME://:smbshare.op")
+ if ( sharename is not None ):
+ sc.remshare(sharename)
+ shares = sc.listshares()
+
+ # Groups
+ l = ldap.initialize("ldap://192.168.1.5")
+ l.simple_bind_s("","")
+ g = l.search_s("dc=intra,dc=informedia,dc=in", ldap.SCOPE_SUBTREE, "objectClass=posixGroup", ['displayName','memberUid'])
+
+ groups = []
+ for ele in g:
+ tp = {}
+ if (ele[1].has_key('displayName') and ele[1]['displayName'][0] == ""):
+ continue
+ if (ele[1].has_key('displayName')):
+ tp['name'] = ele[1]['displayName'][0]
+ if (ele[1].has_key('memberUid')):
+ tp['members'] = ele[1]['memberUid']
+ groups.append(tp)
+
+ return render_to_response('manager/index.html', {'shares': shares,'groups': groups})
+
+def edit(request, sharename=None):
+
+ # Shares
+ sc = Pyro.core.getProxyForURI("PYRONAME://:smbshare.op")
+ if ( sharename is not None ):
+ sc.getshare(sharename)
+ share = sc.getshare(sharename)
+
+ # Groups
+ l = ldap.initialize("ldap://192.168.1.5")
+ l.simple_bind_s("","")
+ g = l.search_s("dc=intra,dc=informedia,dc=in", ldap.SCOPE_SUBTREE, "objectClass=posixGroup", ['displayName','memberUid'])
+
+ groups = []
+ for ele in g:
+ tp = {}
+ if (ele[1].has_key('displayName') and ele[1]['displayName'][0] == ""):
+ continue
+ if (ele[1].has_key('displayName')):
+ tp['name'] = ele[1]['displayName'][0]
+ if (ele[1].has_key('memberUid')):
+ tp['members'] = ele[1]['memberUid']
+ groups.append(tp)
+
+ return render_to_response('manager/edit.html', {'share': share,'groups': groups})
+
+def modify(request):
+
+ # Shares
+ sc = Pyro.core.getProxyForURI("PYRONAME://:smbshare.op")
+
+ try:
+ name = request.POST['name']
+ path = request.POST['path']
+ comment = request.POST['comment']
+ group = request.POST['group']
+ sc.modshare(name, comment, path, group)
+ except (KeyError, Manager.DoesNotExist):
+ return render_to_response('manager/edit.html', {
+ 'error_message': "Form Incomplete"
+ })
+ else:
+ return HttpResponseRedirect('index')
+
+
+ # Groups
+ l = ldap.initialize("ldap://192.168.1.5")
+ l.simple_bind_s("","")
+ g = l.search_s("dc=intra,dc=informedia,dc=in", ldap.SCOPE_SUBTREE, "objectClass=posixGroup", ['displayName','memberUid'])
+
+
+ groups = []
+ for ele in g:
+ tp = {}
+ if (ele[1].has_key('displayName') and ele[1]['displayName'][0] == ""):
+ continue
+ if (ele[1].has_key('displayName')):
+ tp['name'] = ele[1]['displayName'][0]
+ if (ele[1].has_key('memberUid')):
+ tp['members'] = ele[1]['memberUid']
+ groups.append(tp)
+
+ return render_to_response('manager/edit.html', {'share': share,'groups': groups})
+
+
+def form(request):
+
+ sc = Pyro.core.getProxyForURI("PYRONAME://:smbshare.op")
+ # Groups
+ l = ldap.initialize("ldap://192.168.1.5")
+ l.simple_bind_s("","")
+ g = l.search_s("dc=intra,dc=informedia,dc=in", ldap.SCOPE_SUBTREE, "objectClass=posixGroup", ['displayName','memberUid'])
+
+ groups = []
+ for ele in g:
+ tp = {}
+ if (ele[1].has_key('displayName') and ele[1]['displayName'][0] == ""):
+ continue
+ if (ele[1].has_key('displayName')):
+ tp['name'] = ele[1]['displayName'][0]
+ if (ele[1].has_key('memberUid')):
+ tp['members'] = ele[1]['memberUid']
+ groups.append(tp)
+ return render_to_response('manager/form.html', {'groups': groups})
+
+def add(request):
+
+ # Shares
+ sc = Pyro.core.getProxyForURI("PYRONAME://:smbshare.op")
+
+ try:
+ name = request.POST['name']
+ path = request.POST['path']
+ comment = request.POST['comment']
+ group = request.POST['group']
+ sc.addshare(name, comment, path, group)
+ except (KeyError, Manager.DoesNotExist):
+ return render_to_response('manager/form.html', {
+ 'error_message': "Form Incomplete"
+ })
+ else:
+ return HttpResponseRedirect('index')
@@ -0,0 +1,26 @@
+/* -----------------------------------------------------------------------
+
+
+ Blueprint CSS Framework 0.8
+ http://blueprintcss.org
+
+ * Copyright (c) 2007-Present. See LICENSE for more info.
+ * See README for instructions on how to use Blueprint.
+ * For credits and origins, see AUTHORS.
+ * This is a compressed file. See the sources in the 'src' directory.
+
+----------------------------------------------------------------------- */
+
+/* ie.css */
+body {text-align:center;}
+.container {text-align:left;}
+* html .column, * html div.span-1, * html div.span-2, * html div.span-3, * html div.span-4, * html div.span-5, * html div.span-6, * html div.span-7, * html div.span-8, * html div.span-9, * html div.span-10, * html div.span-11, * html div.span-12, * html div.span-13, * html div.span-14, * html div.span-15, * html div.span-16, * html div.span-17, * html div.span-18, * html div.span-19, * html div.span-20, * html div.span-21, * html div.span-22, * html div.span-23, * html div.span-24 {overflow-x:hidden;}
+* html legend {margin:-18px -8px 16px 0;padding:0;}
+ol {margin-left:2em;}
+sup {vertical-align:text-top;}
+sub {vertical-align:text-bottom;}
+html>body p code {*white-space:normal;}
+hr {margin:-8px auto 11px;}
+.clearfix, .container {display:inline-block;}
+* html .clearfix, * html .container {height:1%;}
+fieldset {padding-top:0;}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.

0 comments on commit d40cc94

Please sign in to comment.