Exemplo n.º 1
0
def oparl_file_downloadUrl_data(params):
  file_data = db.get_file(deref={'values': ['file']},
                          search_params={'_id': ObjectId(params['file_id'])})

  if len(file_data) == 0:
    # TODO: Rendere informativere 404 Seite
    abort(404)
  file_data = file_data[0]
  
  # 'file' property is not set (e.g. due to depublication)
  if 'file' not in file_data:
    if 'depublication' in file_data:
      abort(410)  # Gone
    else:
      # TODO: log this as unexplicable...
      abort(500)

  handler = db.get_file_data(file_data['file']['_id'])
  response = make_response(handler.read(), 200)
  response.mimetype = file_data['mimetype']
  response.headers['X-Robots-Tag'] = 'noarchive'
  response.headers['ETag'] = file_data['sha1Checksum']
  response.headers['Last-modified'] = util.rfc1123date(file_data['file']['uploadDate'])
  response.headers['Expires'] = util.expires_date(hours=(24 * 30))
  response.headers['Cache-Control'] = util.cache_max_age(hours=(24 * 30))
  response.headers['Content-Disposition'] = 'attachment; filename=' + file_data['filename']
  return response
Exemplo n.º 2
0
def oparl_file_downloadUrl_data(params):
  file_data = db.get_file(deref={'values': ['file']},
                          search_params={'_id': ObjectId(params['file_id'])})

  if len(file_data) == 0:
    # TODO: Rendere informativere 404 Seite
    abort(404)
  file_data = file_data[0]

  # 'file' property is not set (e.g. due to depublication)
  if 'file' not in file_data:
    if 'depublication' in file_data:
      abort(410)  # Gone
    else:
      # TODO: log this as unexplicable...
      abort(500)

  handler = db.get_file_data(file_data['file']['_id'])
  response = make_response(handler.read(), 200)
  response.mimetype = file_data['mimetype']
  response.headers['X-Robots-Tag'] = 'noarchive'
  response.headers['ETag'] = file_data['sha1Checksum']
  response.headers['Last-modified'] = util.rfc1123date(file_data['file']['uploadDate'])
  response.headers['Expires'] = util.expires_date(hours=(24 * 30))
  response.headers['Cache-Control'] = util.cache_max_age(hours=(24 * 30))
  response.headers['Content-Disposition'] = 'attachment; filename=' + file_data['filename']
  return response
Exemplo n.º 3
0
    def prepare_header_file(self):
        super().prepare_header_file()

        header_file_dict = db.get_file(self.header_file_name,
                                       self.fork_repo.upstream_repo.fullname)
        if header_file_dict:
            self.header_file = db.file_dict_to_obj(header_file_dict)
            self.header_file.content = gc.get_file_content(self.header_file)
            # secret key 개수는 파일에 #Secret Key Count = 10 이런식으로 적혀짐
            m = re.search(self._get_comment_str('Secret Key Count = (\d+)'),
                          self.header_file.content)
            if m:
                self.secret_key_cnt = int(m.group(1))
            else:
                self.secret_key_cnt = 0
        else:
            # 헤더 파일 내용
            self.secret_key_cnt = 0
            content = self._get_init_header()

            self.header_file = self.fork_repo.create_file(
                file_fullname=self.header_file_name,
                title='Secret key leak fix',
                content=content,
                branch='code-fix')
Exemplo n.º 4
0
def foo(root_parent , user_name):
	print("inside foo")
	fs.read(db.get_file(user_name))
	try:
		root_parent.destroy()
	except Exception as e:
		print ( e )
	root3 = tk.Tk()
	
	welcome = tk.Label(root3, text = "Welcome "+str(user_name)+',' , font = ('Segoe Script',16,'bold') ,bg ='dark blue', fg ='white')
	welcome.pack(padx = 50 , pady = 30 )
	welcome.place(x = 150, y = 10 )
	
	x_b = 700
	y_b = 70
	step_b = 40
	button = []
	ind = 0
	hell = ''
	
	
	stext = ScrolledText(root3 ,bg='white', height=10)
	print(type(stext))
	f = open(db.get_file(user_name),"r")
	f1 = f.read()
	stext.insert(tk.END, f1)
	f.close()
	stext.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)
	stext.focus_set()
	#print(stext.get(0))
	def create_button(i, ind):
		button.append(tk.Button(root3, text = i , font = ("Segoe Script", 10,"bold"),command = lambda:fs.begin(i)))
		button[ind].pack(side=tk.RIGHT)
		button[ind].place(x = x_b, y = y_b)
	for i in fs.D.keys():
		print("fs.D.keyts: ",str(i))
		hell = i
		create_button(i,ind)
		y_b = y_b + step_b
		ind = ind + 1
	run_b = tk.Button(root3, text = "EDITING DONE",font = ("Segoe Script", 10,"bold"), command = lambda: write_into_file(tk.Text.get(stext,"1.0",'end'), user_name))
	run_b.pack(padx = 100, pady = 300) 
	root3.minsize(600,400)
	root3.mainloop()
Exemplo n.º 5
0
def attachment_view(attachment_id, extension, savefile=False):
    """
    Abruf/Download eines Attachments
    """
    attachment_info = db.get_attachment(attachment_id)
    #pprint.pprint(attachment_info)
    if attachment_info is None:
        # TODO: Rendere informativere 404 Seite
        abort(404)
    # extension doesn't match file extension (avoiding arbitrary URLs)
    proper_extension = attachment_info['filename'].split('.')[-1]
    if proper_extension != extension:
        abort(404)

    # 'file' property is not set (e.g. due to depublication)
    if 'file' not in attachment_info:
        if 'depublication' in attachment_info:
            abort(410)  # Gone
        else:
            # TODO: log this as unexplicable...
            abort(500)

    # handle conditional GET
    if 'If-Modified-Since' in request.headers:
        file_date = attachment_info['file']['uploadDate'].replace(tzinfo=None)
        request_date = util.parse_rfc1123date(request.headers['If-Modified-Since'])
        difference = file_date - request_date
        if difference < datetime.timedelta(0, 1):  # 1 second
            return Response(status=304)

    #if 'if-none-match' in request.headers:
    #    print "Conditional GET: If-None-Match"
    # TODO: handle ETag in request

    handler = db.get_file(attachment_info['file']['_id'])
    response = make_response(handler.read(), 200)
    response.mimetype = attachment_info['mimetype']
    response.headers['X-Robots-Tag'] = 'noarchive'
    response.headers['ETag'] = attachment_info['sha1']
    response.headers['Last-modified'] = util.rfc1123date(
                    attachment_info['file']['uploadDate'])
    response.headers['Expires'] = util.expires_date(
                                        hours=(24 * 30))
    response.headers['Cache-Control'] = util.cache_max_age(
                                            hours=(24 * 30))
    # Save to file option
    if savefile == True:
        response.headers['Content-Disposition'] = 'attachment; filename=%s' % attachment_info['filename']
        response.headers['X-Robots-Tag'] = 'noindex'
        # See https://support.google.com/webmasters/answer/139394
        response.headers['Link'] = '<%sanhang/%s.%s>; rel="canonical"' % (
            app.config['BASE_URL'], attachment_id, extension)
    return response
Exemplo n.º 6
0
def create():
    if request.method=='POST':
        try:
            doc_name, data, doc_id, doc=get_file()
            print(type(doc), file=sys.stdout)
        except:
            pass
        try:
            data=data.decode()
        except:
            data=''
        complete_data = {'name':doc_name,'data':data,'id':doc_id,'doc':doc,'typeOfdoc':str(type(doc))}
        json_data= json.dumps(complete_data)
        return json_data
Exemplo n.º 7
0
 def get(self):
     hsh = self.get_argument('file', default='')
     fileinfo = db.get_file(hsh)
     if not fileinfo:
         self.write({
             'result': False,
             'msg': 'Invalid file id',
             })
         return
     self.set_header('Content-Type', 'application/octet-stream')
     self.set_header(
         'Content-Disposition',
         'attachment; filename="%s"' % fileinfo['name'],
         )
     self.write(fileinfo['content'])
Exemplo n.º 8
0
 def get(self):
     hsh = self.get_argument('file', default='')
     fileinfo = db.get_file(hsh)
     if not fileinfo:
         self.write({
             'result': False,
             'msg': 'Invalid file id',
         })
         return
     self.set_header('Content-Type', 'application/octet-stream')
     self.set_header(
         'Content-Disposition',
         'attachment; filename="%s"' % fileinfo['name'],
     )
     self.write(fileinfo['content'])
Exemplo n.º 9
0
def attachment_download(attachment_id, extension):
    """
    Download eines Attachments
    """
    attachment_info = db.get_attachment(attachment_id)
    #pprint.pprint(attachment_info)
    if attachment_info is None:
        # TODO: Rendere informativere 404 Seite
        abort(404)
    # extension doesn't match file extension (avoiding arbitrary URLs)
    proper_extension = attachment_info['filename'].split('.')[-1]
    if proper_extension != extension:
        abort(404)

    # 'file' property is not set (e.g. due to depublication)
    if 'file' not in attachment_info:
        if 'depublication' in attachment_info:
            abort(410)  # Gone
        else:
            # TODO: log this as unexplicable...
            abort(500)

    # handle conditional GET
    if 'If-Modified-Since' in request.headers:
        file_date = attachment_info['file']['uploadDate'].replace(tzinfo=None)
        request_date = util.parse_rfc1123date(request.headers['If-Modified-Since'])
        difference = file_date - request_date
        if difference < datetime.timedelta(0, 1):  # 1 second
            return Response(status=304)

    #if 'if-none-match' in request.headers:
    #    print "Conditional GET: If-None-Match"
    # TODO: handle ETag in request

    handler = db.get_file(attachment_info['file']['_id'])
    response = make_response(handler.read(), 200)
    response.mimetype = attachment_info['mimetype']
    response.headers['X-Robots-Tag'] = 'noarchive'
    response.headers['ETag'] = attachment_info['sha1']
    response.headers['Last-modified'] = util.rfc1123date(
                    attachment_info['file']['uploadDate'])
    response.headers['Expires'] = util.expires_date(
                                        hours=(24 * 30))
    response.headers['Cache-Control'] = util.cache_max_age(
                                            hours=(24 * 30))
    return response
Exemplo n.º 10
0
def attachment_download(attachment_id, extension):
    """
    Download eines Attachments
    """
    attachment_info = db.get_attachment(attachment_id)
    #pprint.pprint(attachment_info)
    if attachment_info is None:
        # TODO: Rendere informativere 404 Seite
        abort(404)
    # extension doesn't match file extension (avoiding arbitrary URLs)
    proper_extension = attachment_info['filename'].split('.')[-1]
    if proper_extension != extension:
        abort(404)

    # 'file' property is not set (e.g. due to depublication)
    if 'file' not in attachment_info:
        if 'depublication' in attachment_info:
            abort(410)  # Gone
        else:
            # TODO: log this as unexplicable...
            abort(500)

    # handle conditional GET
    if 'If-Modified-Since' in request.headers:
        file_date = attachment_info['file']['uploadDate'].replace(tzinfo=None)
        request_date = util.parse_rfc1123date(
            request.headers['If-Modified-Since'])
        difference = file_date - request_date
        if difference < datetime.timedelta(0, 1):  # 1 second
            return Response(status=304)

    #if 'if-none-match' in request.headers:
    #    print "Conditional GET: If-None-Match"
    # TODO: handle ETag in request

    handler = db.get_file(attachment_info['file']['_id'])
    response = make_response(handler.read(), 200)
    response.mimetype = attachment_info['mimetype']
    response.headers['X-Robots-Tag'] = 'noarchive'
    response.headers['ETag'] = attachment_info['sha1']
    response.headers['Last-modified'] = util.rfc1123date(
        attachment_info['file']['uploadDate'])
    response.headers['Expires'] = util.expires_date(hours=(24 * 30))
    response.headers['Cache-Control'] = util.cache_max_age(hours=(24 * 30))
    return response
Exemplo n.º 11
0
def file_info(file_name=None):
    '''file info view'''
    file_name=request.args.get('file',0, type=str)
    #TODO: file_name validation goes here
    f=get_file(file_name)
    if f:
       t='''{"file": {
            filename: $name,
            size: $size,
            m_time: $m_time,
            c_time: $c_time,
        },
        }
       '''
       template= Template(t)    
       return template.substitute(name=f.name, size=f.size, m_time=f.time_modified, c_time=f.time_created)
    else:
       return 'Error, file not found in db'
Exemplo n.º 12
0
def oparl_file_data(params):
  data = db.get_file(search_params={'_id': ObjectId(params['_id'])})
  if len(data) == 1:
    data[0]['body'] = generate_single_url(params=params, type='body', id=data[0]['body'].id)
    data[0]['accessUrl'] = generate_sublist_url(params=params, main_type='file', sublist_type='accessUrl')
    data[0]['downloadUrl'] = generate_sublist_url(params=params, main_type='file', sublist_type='downloadUrl')
    data[0]['meeting'] = generate_sublist_url(params=params, main_type='file', sublist_type='meeting')
    data[0]['paper'] = generate_sublist_url(params=params, main_type='file', sublist_type='paper')
    if 'masterFile' in data[0]:
      data[0]['masterFile'] = generate_single_url(params=params, type='file', id=data[0]['mainFile'].id)
    data[0]['derivativeFile'] = generate_sublist_url(params=params, main_type='file', sublist_type='derivativeFile')
    data[0]['@type'] = 'OParlPaper'
    data[0]['@id'] = data[0]['_id']
    if 'file' in data[0]:
      del data[0]['file']
    return data[0]
  elif len(data) == 0:
    abort(404)
Exemplo n.º 13
0
def oparl_file_data(params):
  data = db.get_file(search_params={'_id': ObjectId(params['_id'])})
  if len(data) == 1:
    data = oparl_file_layout(data[0], params)
    # Get Backrefs for Meeting
    data['meeting'] = []
    meeting = db.get_meeting(search_params={'invitation': DBRef('file', ObjectId(params['_id']))})
    if len(meeting):
      data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], meeting[0]['_id'], generate_postfix(params)))
    meeting = db.get_meeting(search_params={'resultsProtocol': DBRef('file', ObjectId(params['_id']))})
    if len(meeting):
      data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], meeting[0]['_id'], generate_postfix(params)))
    meeting = db.get_meeting(search_params={'verbatimProtocol': DBRef('file', ObjectId(params['_id']))})
    if len(meeting):
      data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], meeting[0]['_id'], generate_postfix(params)))
    meeting = db.get_meeting(search_params={'verbatimProtocol': DBRef('auxiliaryFile', ObjectId(params['_id']))})
    for single_meeting in meeting:
      data['meeting'].append("%s/oparl/meeting/%s%s" % (app.config['api_url'], single_meeting['_id'], generate_postfix(params)))
    if len(data['meeting']) == 0:
      del data['meeting']
    # Get Backrefs for AgendaItem
    data['agendaItem'] = []
    agendaItem = db.get_agendaItem(search_params={'resolutionFile': DBRef('file', ObjectId(params['_id']))})
    if len(agendaItem):
      data['agendaItem'].append("%s/oparl/agendaItem/%s%s" % (app.config['api_url'], agendaItem[0]['_id'], generate_postfix(params)))
    agendaItem = db.get_agendaItem(search_params={'auxiliaryFile': DBRef('file', ObjectId(params['_id']))})
    for single_agendaItem in agendaItem:
      data['agendaItem'].append("%s/oparl/agendaItem/%s%s" % (app.config['api_url'], single_agendaItem['_id'], generate_postfix(params)))
    if len(data['agendaItem']) == 0:
      del data['agendaItem']
    # Get Backrefs for Paper
    data['paper'] = []
    paper = db.get_agendaItem(search_params={'mainFile': DBRef('file', ObjectId(params['_id']))})
    if len(paper):
      data['paper'].append("%s/oparl/paper/%s%s" % (app.config['api_url'], paper[0]['_id'], generate_postfix(params)))
    paper = db.get_agendaItem(search_params={'auxiliaryFile': DBRef('file', ObjectId(params['_id']))})
    for single_paper in paper:
      data['paper'].append("%s/oparl/paper/%s%s" % (app.config['api_url'], single_paper['_id'], generate_postfix(params)))
    if len(data['paper']) == 0:
      del data['paper']
    return data
  elif len(data) == 0:
    abort(404)
Exemplo n.º 14
0
    def prepare(self):
        assert self.is_prepared == False
        self.is_prepared = True

        self.fork_upstream_repo()

        # check gitignore file
        gitignore_file_dict = db.get_file(
            fullname='.gitignore', repo_fullname=self.upstream_repo.fullname)
        if gitignore_file_dict:
            self.gitignore_file = db.file_dict_to_obj(gitignore_file_dict)
            self.gitignore_file.content = gc.get_file_content(
                self.gitignore_file)
        # 없으면 생성
        else:
            # 헤더 파일 내용
            self.gitignore_file = self.fork_repo.create_file(
                '.gitignore', 'Secret key leak fix', '', branch='code-fix')
            self.gitignore_file.content = ''
Exemplo n.º 15
0
def oparl_file_accessUrl_data(params):
  file_data = db.get_file(deref={'values': ['file']},
                              search_params={'_id': ObjectId(params['file_id'])})

  if len(file_data) == 0:
    # TODO: Rendere informativere 404 Seite
    abort(404)
  file_data = file_data[0]
  # extension doesn't match file extension (avoiding arbitrary URLs)
  #proper_extension = attachment_info['filename'].split('.')[-1]
  #if proper_extension != extension:
  #    abort(404)

  # 'file' property is not set (e.g. due to depublication)
  if 'file' not in file_data:
    if 'depublication' in file_data:
      abort(410)  # Gone
    else:
      # TODO: log this as unexplicable...
      abort(500)

  # handle conditional GET
  #if 'If-Modified-Since' in request.headers:
  #  file_date = attachment_info['file']['uploadDate'].replace(tzinfo=None)
  #  request_date = util.parse_rfc1123date(request.headers['If-Modified-Since'])
  #  difference = file_date - request_date
  #  if difference < datetime.timedelta(0, 1):  # 1 second
  #    return Response(status=304)

  #if 'if-none-match' in request.headers:
  #    print "Conditional GET: If-None-Match"
  # TODO: handle ETag in request

  handler = db.get_file_data(file_data['file']['_id'])
  response = make_response(handler.read(), 200)
  response.mimetype = file_data['mimetype']
  response.headers['X-Robots-Tag'] = 'noarchive'
  response.headers['ETag'] = file_data['sha1Checksum']
  response.headers['Last-modified'] = util.rfc1123date(file_data['file']['uploadDate'])
  response.headers['Expires'] = util.expires_date(hours=(24 * 30))
  response.headers['Cache-Control'] = util.cache_max_age(hours=(24 * 30))
  return response
Exemplo n.º 16
0
def file_show(file_id):
  """
  Anzeigen eines Files
  """
  result = db.get_file(search_params = {'_id': ObjectId(file_id)},
                        deref = {'values': ['body']})
  if len(result) == 0:
    abort(404)
  # add meeting
  usage = []
  meeting_invitation = db.get_meeting(search_params = {'invitation': DBRef('file', ObjectId(file_id))})
  for item in meeting_invitation:
    usage.append({ 'data': item, 'type': 'meeting', 'function': 'invitation'})
  meeting_resultsProtocol = db.get_meeting(search_params = {'resultsProtocol': DBRef('file', ObjectId(file_id))})
  for item in meeting_resultsProtocol:
    usage.append({ 'data': item, 'type': 'meeting', 'function': 'resultsProtocol'})
  meeting_verbatimProtocol = db.get_meeting(search_params = {'verbatimProtocol': DBRef('file', ObjectId(file_id))})
  for item in meeting_verbatimProtocol:
    usage.append({ 'data': item, 'type': 'meeting', 'function': 'verbatimProtocol'})
  meeting_auxiliaryFile =  db.get_meeting(search_params = {'auxiliaryFile': DBRef('file', ObjectId(file_id))})
  for item in meeting_auxiliaryFile:
    usage.append({ 'data': item, 'type': 'meeting', 'function': 'auxiliaryFile'})
  
  # add agendaItem
  agendaItem_resolutionFile = db.get_agendaItem(search_params = {'resolutionFile': DBRef('file', ObjectId(file_id))})
  for item in agendaItem_resolutionFile:
    usage.append({ 'data': item, 'type': 'agendaItem', 'function': 'resolutionFile'})
  agendaItem_auxiliaryFile = db.get_agendaItem(search_params = {'auxiliaryFile': DBRef('file', ObjectId(file_id))})
  for item in agendaItem_auxiliaryFile:
    usage.append({ 'data': item, 'type': 'agendaItem', 'function': 'auxiliaryFile'})
  
  # add paper
  paper_mainFile = db.get_paper(search_params = {'mainFile': DBRef('file', ObjectId(file_id))})
  for item in paper_mainFile:
    usage.append({ 'data': item, 'type': 'paper', 'function': 'mainFile'})
  paper_auxiliaryFile = db.get_paper(search_params = {'auxiliaryFile': DBRef('file', ObjectId(file_id))})
  for item in paper_auxiliaryFile:
    usage.append({ 'data': item, 'type': 'paper', 'function': 'auxiliaryFile'})
  
  if len(usage):
    result[0]['usage'] = usage
  return render_template('file_details.html', file=result[0])
Exemplo n.º 17
0
def oparl_file_accessUrl_data(params):
  file_data = db.get_file(deref={'values': ['file']},
                              search_params={'_id': ObjectId(params['file_id'])})

  if len(file_data) == 0:
    # TODO: Rendere informativere 404 Seite
    abort(404)
  file_data = file_data[0]
  # extension doesn't match file extension (avoiding arbitrary URLs)
  #proper_extension = attachment_info['filename'].split('.')[-1]
  #if proper_extension != extension:
  #    abort(404)

  # 'file' property is not set (e.g. due to depublication)
  if 'file' not in file_data:
    if 'depublication' in file_data:
      abort(410)  # Gone
    else:
      # TODO: log this as unexplicable...
      abort(500)

  # handle conditional GET
  #if 'If-Modified-Since' in request.headers:
  #  file_date = attachment_info['file']['uploadDate'].replace(tzinfo=None)
  #  request_date = util.parse_rfc1123date(request.headers['If-Modified-Since'])
  #  difference = file_date - request_date
  #  if difference < datetime.timedelta(0, 1):  # 1 second
  #    return Response(status=304)

  #if 'if-none-match' in request.headers:
  #    print "Conditional GET: If-None-Match"
  # TODO: handle ETag in request

  handler = db.get_file_data(file_data['file']['_id'])
  response = make_response(handler.read(), 200)
  response.mimetype = file_data['mimetype']
  response.headers['X-Robots-Tag'] = 'noarchive'
  response.headers['ETag'] = file_data['sha1Checksum']
  response.headers['Last-modified'] = util.rfc1123date(file_data['file']['uploadDate'])
  response.headers['Expires'] = util.expires_date(hours=(24 * 30))
  response.headers['Cache-Control'] = util.cache_max_age(hours=(24 * 30))
  return response
Exemplo n.º 18
0
def file_filter(cur_file: File, is_file):  # true가 우리가 찾는 파일 or 그냥 폴더
    if cur_file.name not in FILE_FILTER['SELECT_NAME']:
        if ignore_regex.search(cur_file.name):
            return False

        if not is_file:
            return True

        if not extension_regex.search(cur_file.name):
            return False

    prev_file = db.get_file(cur_file.fullname, cur_file.repo_fullname)

    if not prev_file:  # db에 파일이 기록되지 않음
        db.add_file(cur_file)
        return True

    prev_file = db.file_dict_to_obj(prev_file)
    if cur_file.sha != prev_file.sha:  # db에 파일이 기록됨 -> 업데이트 되었는가?
        db.update_file(fullname=prev_file.fullname, sha=cur_file.sha)
        return True

    return False
Exemplo n.º 19
0
def file_show(file_id):
    """
  Anzeigen eines Files
  """
    result = db.get_file(search_params={'_id': ObjectId(file_id)},
                         deref={'values': ['body']})
    if len(result) == 0:
        abort(404)
    # add meeting
    usage = []
    meeting_invitation = db.get_meeting(
        search_params={'invitation': DBRef('file', ObjectId(file_id))})
    for item in meeting_invitation:
        usage.append({
            'data': item,
            'type': 'meeting',
            'function': 'invitation'
        })
    meeting_resultsProtocol = db.get_meeting(
        search_params={'resultsProtocol': DBRef('file', ObjectId(file_id))})
    for item in meeting_resultsProtocol:
        usage.append({
            'data': item,
            'type': 'meeting',
            'function': 'resultsProtocol'
        })
    meeting_verbatimProtocol = db.get_meeting(
        search_params={'verbatimProtocol': DBRef('file', ObjectId(file_id))})
    for item in meeting_verbatimProtocol:
        usage.append({
            'data': item,
            'type': 'meeting',
            'function': 'verbatimProtocol'
        })
    meeting_auxiliaryFile = db.get_meeting(
        search_params={'auxiliaryFile': DBRef('file', ObjectId(file_id))})
    for item in meeting_auxiliaryFile:
        usage.append({
            'data': item,
            'type': 'meeting',
            'function': 'auxiliaryFile'
        })

    # add agendaItem
    agendaItem_resolutionFile = db.get_agendaItem(
        search_params={'resolutionFile': DBRef('file', ObjectId(file_id))})
    for item in agendaItem_resolutionFile:
        usage.append({
            'data': item,
            'type': 'agendaItem',
            'function': 'resolutionFile'
        })
    agendaItem_auxiliaryFile = db.get_agendaItem(
        search_params={'auxiliaryFile': DBRef('file', ObjectId(file_id))})
    for item in agendaItem_auxiliaryFile:
        usage.append({
            'data': item,
            'type': 'agendaItem',
            'function': 'auxiliaryFile'
        })

    # add paper
    paper_mainFile = db.get_paper(
        search_params={'mainFile': DBRef('file', ObjectId(file_id))})
    for item in paper_mainFile:
        usage.append({'data': item, 'type': 'paper', 'function': 'mainFile'})
    paper_auxiliaryFile = db.get_paper(
        search_params={'auxiliaryFile': DBRef('file', ObjectId(file_id))})
    for item in paper_auxiliaryFile:
        usage.append({
            'data': item,
            'type': 'paper',
            'function': 'auxiliaryFile'
        })

    if len(usage):
        result[0]['usage'] = usage
    return render_template('file_details.html', file=result[0])
Exemplo n.º 20
0
f = open('/home/pi/iot.config/raspberry_pi_def.csv', 'r')
reader = csv.DictReader(f)
for line in reader:
    config = line

count = int(config['db_interval'])
DB = False

while True:
    time.sleep(5)
    try:
        if config['dropbox'] == 'ON':
            count += 5
            if count >= int(config['db_interval']):
                count = 0
                db.get_file("command")
                DB = True

        file = open("/home/pi/command/command.txt", "r")
        command_list = file.readlines()
        file.close()

        if "DONE" in command_list[-1]:
            continue

        f = open("/home/pi/command/command.txt", "a")
        f.write("\nDONE " + time.strftime("%Y/%m/%d %H:%M:%S"))
        f.close()

        if DB == True:
            db.send_file("/home/pi/command/command.txt", "command")
Exemplo n.º 21
0
def write_into_file(text, user_name):
	file_name = db.get_file(user_name)
	f = open(file_name,"w")
	f.write(text)
	f.close()
	fs.read(file_name)
Exemplo n.º 22
0
#cording:utf-8
import sys, os
import db

ip_dir = ['iot.config', 'command', 'receive_data']
dl_list = ['iot.config', 'iot_kit', 'ShareMaster', 'command']
up_list = {
    'sensor_data': 'data',
    'receive_data': 'senddata',
    'Raspberrypi_list': 'RaspberryPi_list'
}

dir = sys.argv
cont_dir = len(dir) - 1
for i in range(cont_dir):
    if dir[i + 1] in dl_list:
        if dir[i + 1] in ip_dir:
            db.get_file(dir[i + 1])
        else:
            db.get_file(dir[i + 1], ip="")
    elif dir[i + 1] in up_list:
        file_list = os.listdir("/home/pi/" + up_list[dir[i + 1]])
        for file in file_list:
            if dir[i + 1] in ip_dir:
                db.send_file("/home/pi/" + up_list[dir[i + 1]] + "/" + file,
                             dir[i + 1])
            else:
                db.send_file("/home/pi/" + up_list[dir[i + 1]] + "/" + file,
                             dir[i + 1],
                             ip="")
Exemplo n.º 23
0
def oparl_body_file_data(params):
  data = db.get_file(file_list=True,
                     search_params = {'body': DBRef('body', ObjectId(params['body_id']))},
                     add_prefix = "%s/oparl/file/" % app.config['api_url'],
                     add_postfix = generate_postfix(params))
  return data
Exemplo n.º 24
0
def oparl_files_data(params):
  return db.get_file(file_list = True,
                     add_prefix = "%s/oparl/file/" % app.config['api_url'],
                     add_postfix=generate_postfix(params))
Exemplo n.º 25
0
#cording:utf-8
import time, csv, sys
import db

f = open('/home/pi/iot.config/raspberry_pi_def.csv', 'r')
reader = csv.DictReader(f)
for line in reader:
        config = line

dl = 'ShareMaster'
up = 'sensor_data'

raspi_sid = sys.argv[1]
while True:
	try:
		if config["mode"] != "3": 
			db.get_file(dl, ip="")

		file = raspi_sid+'_'+time.strftime("%Y%m%d")+'.csv'
		db.send_file("/home/pi/data/"+file, up, ip="")
	except Exception as e:
		print(e)
	
	time.sleep(int(config['db_interval']))
Exemplo n.º 26
0
def oparl_file_data(params):
  data = db.get_file(search_params={'_id': ObjectId(params['_id'])})
  if len(data) == 1:
    return (oparl_file_layout(data[0], params))
  elif len(data) == 0:
    abort(404)