Beispiel #1
0
    def verify_file_exists(dbfn): # DONT KNOW THAT WE NEED TO DO THIS!!
        try:
            file = os.readlink(dbfn)
            if file == '/dev/null' or \
              re.match(r'pipe:\[\d+\]',file) or \
              re.match(r'socket:\[\d+\]',file) or \ # check if file is open
	      re.match(r'.csv',file) or \ # check if file is extension FIX THIS -- CSV OR FEATHER?
	      dbfn in os.dir(inpath): # check if file is in directory -- FIX THIS // INVERT THESE STEPS
                file = None
        except OSError as err:
            if err.errno == 2:     
                file = None
            else:
                raise(err) # SHOULD IGNORE RATHER THAN ASSERT ERROR
                
        yield (filename)
Beispiel #2
0
    for width in primes:
        if N % width == 0:
            for height in primes:
                if width * height == N:
                    return (width, height)  # N % height == 0
    return (0, 0)


print(produit(21))

from os import getcwd as dir, chdir as cd

cd('U:\\')
cd('C:\\Users\\Benjamin LOISON\\Desktop\\BensFolder\\School\\CPGE\\Fenelon\\MPSI\\IPT\\19\\02\\20'
   )
print(dir())

# print(type(octet))
# valeur = octet[0]

source = open('message.bin', 'rb')
octets = [source.read(1)]
while octets[len(octets) - 1] != bytes(b''):
    octets += [source.read(1)]
source.close()
octets = octets[:len(octets) - 1]
print(octets)
taille = len(octets)

binaries = []
for octet in octets:
Beispiel #3
0
# -*- coding: utf-8 -*-
"""s3_bucket_upload.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1W15rcSlBs5AuqGXYHAegwadr-s209jmk
"""

import boto3
import os

access_key = "AKIAJL2IQX7Z5KVSM5ZQ"
secret_access_key = "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"

client = boto3.client('s3',
                      access_key=access_key,
                      secret_access_key=secret_access_key)
for file in os.dir():
    if '.py' in file:
        bucket_name = ""
        path = "python/" + str(file)
        client.upload_file(file, bucket_name, path)
Beispiel #4
0
plt.title('5-th order approximation of image')
plt.show()

#-------------------------------

 #----------------------------------------------------------------------------
 #       Useful functions for converting  images  <-->  vectors
 #----------------------------------------------------------------------------
 row = 64
 col = 64
 
 image_vector  = lambda(Bitmap) double(reshape(Bitmap,row*col,1))
 vector_image  = lambda(Vec) reshape( uint8( min(max(Vec,0),255) ), row, col)
 vector_render = lambda(Vec) plt.imshow(vector_image(Vec), cmap='gray')

filenames = os.dir('*.bmp')
n = len(filenames)
for i in range(n):
  Image_File = filenames[i]
  Face_Matrix = img.imread(Image_File)
  F[i,:] = image_vector(Face_Matrix)  # the i-th row of F is the i-th image
end

#-------------------------------

m = np.mean(F).T   # m is a vector containing the means of columns of F
vector_render(m)
plt.show()

image_vector  = lambda(Bitmap) double(reshape(Bitmap,row*col,1))
vector_image  = lambda(Vec) reshape( min(max(Vec,0),255), row, col)
# Operational Sistem
import os

os.system('Comando')  # Executa comandos através do python
os.dir()  # Exibe o diretório atual
os.name  # Exibe o tipo de sistemas (nt = windows)
os.mkdir()  # Cria diretórios
Beispiel #6
0
import os
print(os.dir())
Beispiel #7
0
import os
print("hello world!---maomin")
os.dir("")
print("maomin")
Beispiel #8
0
 def __python_mods_in(path):
     mods = set()
     for item in os.dir(path):
         is_python.match(item)
         mods.add(os.splitext(item)[0])
     return mods
Beispiel #9
0
import os
import time

os.dir(current)
print('test')
Beispiel #10
0
#创建文件夹
#os.mkdir('house')#当前路径,创建文件夹
os.mkdir('../girt')#相对路径或绝对路径,+ 文件夹

#pwd
p=os.getcwd()#得到当前路径保存下来
print('当前路径是:%s'%p)

#修改默认路径  change
os.chdir('./house')
print('修改之后的默认路径是:%s'%os.getcwd())

f=open('1.txt','w')
f.close()

os.dir('xiaohua')#创建到了新的路径下

os.rmdir('xiaohua')#删除文件夹

os.chdir('../')
#当文件夹空的时候可以用os.chdir删除文件夹
#当文件空的时候可以用:
#当前路径../
#empty 空的