def __init__(self, core, options): self._core = core if os.name == "posix": self._accounts_dir = os.path.join(os.environ['HOME'], ".amsn2") elif os.name == "nt": self._accounts_dir = os.path.join(os.environ['USERPROFILE'], "amsn2") else: self._accounts_dir = os.path.join(os.curdir, "amsn2_accounts") try : os.makedirs(self._accounts_dir, 0700) except : pass self.reload() if options.account is not None: pv = [p for p in self.accountviews if p.email == options.account] if pv: pv = pv[0] self.accountviews.remove(pv) else: pv = AccountView() pv.email = options.account pv.password = options.password self.accountviews.insert(0, pv)
def loadAccount(self, dir): accview = None accpath = os.path.join(dir, "account.xml") accfile = file(accpath, "r") root_tree = ElementTree(file=accfile) accfile.close() account = root_tree.getroot() if account.tag == "aMSNAccount": accview = AccountView() #email emailElmt = account.find("email") if emailElmt is None: return None accview.email = emailElmt.text #nick nickElmt = account.find("nick") if nickElmt is None: return None if nickElmt.text: accview.nick.appendText(nickElmt.text) #TODO: parse... #presence presenceElmt = account.find("presence") if presenceElmt is None: return None accview.presence = presenceElmt.text #password passwordElmt = account.find("password") if passwordElmt is None: accview.password = None else: accview.password = self._core._backend_manager.getPassword(passwordElmt) #save_password savePassElmt = account.find("save_password") if savePassElmt.text == "False": accview.save_password = False else: accview.save_password = True #autoconnect saveAutoConnect = account.find("autoconnect") if saveAutoConnect.text == "False": accview.autologin = False else: accview.autologin = True #TODO: use backend & all #dp dpElmt = account.find("dp") #TODO #TODO: preferred_ui ? accview.save = True return accview
def __init__(self, core, options): self._core = core self.reload() if options.account is not None: pv = [p for p in self.accountviews if p.email == options.account] if pv: pv = pv[0] self.accountviews.remove(pv) else: pv = AccountView(core, options.account) pv.password = options.password self.accountviews.insert(0, pv)
def account_detail(identifier): account = AccountView.get_account_with_identifier(identifier) data = {'type': account.account_type, 'balance': account.balance} response = app.response_class(response=json.dumps(data), status=200, mimetype='application/json') return response
def account_create(): if request.method == 'POST': data = request.get_json() try: new = AccountView.add_account(data) response = app.response_class(response=json.dumps(new), status=201, mimetype='application/json') except Exception as e: data = {'exception': str(e)} response = app.response_class(response=json.dumps(data), status=400, mimetype='application/json') return response
from django.conf.urls.defaults import * from views import AccountView, ContainerView, ObjectView urlpatterns = patterns( '', url(r'^v1/([-a-zA-Z0-9_]+)$', AccountView.as_view(), name='account_services'), url(r'^v1/([-a-zA-Z0-9_]+)/([-a-zA-Z0-9_%]+)$', ContainerView.as_view(), name='container_services'), url(r'^v1/([-a-zA-Z0-9_]+)/([-a-zA-Z0-9_%]+)/(.*)$', ObjectView.as_view(), name='object_services'), )
from django.conf.urls import include, url from django.contrib import admin from case.views import (AccountsListView, AccountView, DepartmentsListView, DepartmentView, FactPaymentsListView, PaymentView, PlanedPaymentsListView, ProjectsListView, ProjectView) urlpatterns = [ url(r'account/$', AccountView.as_view(), name='account'), url(r'account/(?P<pk>\d+)/$', AccountView.as_view(), name='account'), url(r'accounts/$', AccountsListView.as_view(), name='accounts'), url(r'department/$', DepartmentView.as_view(), name='department'), url(r'department/(?P<pk>\d+)/$', DepartmentView.as_view(), name='department'), url(r'departments/$', DepartmentsListView.as_view(), name='departments'), url(r'project/$', ProjectView.as_view(), name='project'), url(r'project/(?P<pk>\d+)/$', ProjectView.as_view(), name='project'), url(r'projects/$', ProjectsListView.as_view(), name='projects'), url(r'payment/$', PaymentView.as_view(), name='payment'), url(r'payment/(?P<pk>\d+)/$', PaymentView.as_view(), name='payment'), url(r'payments/planed/$', PlanedPaymentsListView.as_view(), name='planed-payments'), url(r'payments/fact/$', FactPaymentsListView.as_view(), name='fact-payments'), ]
from django.conf.urls.defaults import * from views import AccountView, ContainerView, ObjectView urlpatterns = patterns('', url(r'^v1/([-a-zA-Z0-9_]+)$', AccountView.as_view(), name='account_services'), url(r'^v1/([-a-zA-Z0-9_]+)/([-a-zA-Z0-9_%]+)$', ContainerView.as_view(), name='container_services'), url(r'^v1/([-a-zA-Z0-9_]+)/([-a-zA-Z0-9_%]+)/(.*)$', ObjectView.as_view(), name='object_services'), )